Hi,

The KNN query you implemented does not make sense. Please describe the
purpose of this query. Are you looking for a KNN join query? For each
point in A, find its K nearest neighbors in B? Or a regular KNN query,
for a single point X, find its K Nearest Neighbor in a Dataset B?

Other queries look fine to me.

Thanks,
Jia

On Sun, Jun 4, 2023 at 5:33 PM Vigneswaran S <[email protected]> wrote:
>
> Dear Sedona Team,
>
> I am trying to implement spatial queries using SedonaSQL in Pure SQL
> environment, from data stored in Hive tables, following the steps mentioned
> in the link below.
>
> https://sedona.apache.org/latest-snapshot/tutorial/sql-pure-sql/
>
> The implementation of the queries are as follows
>
> *1*. *Circle range query*
> SELECT COUNT(*) FROM table_name WHERE
> ST_Intersects(ST_Buffer(ST_Point(x1,y1), radius), ST_Point(x, y));
>
> *2. BBOX range query*
> SELECT COUNT(*) FROM table_name WHERE
> ST_Contains(ST_GeomFromText('POLYGON ((x1 y1, x2 y2, .. , x1 y1))'),
> ST_Point(x, y));
>
> *3. k-NN query (k=10)*
> SELECT ST_Distance(ST_Point(x1, y1), ST_Point(x, y)) as distance, x, y FROM
> table_name ORDER BY distance ASC LIMIT 10;
>
> Kindly let me know the optimised way to implement the above queries
> (especially k-NN).
>
> Thanks & Regards
> Vigneswaran

Reply via email to