Search code examples
hivegisesri

calculate distance between points and a center within a radius HIVE


Im using the following to get all points from my hive datbase that are within 200m of my center.

SELECT * FROM mytable
WHERE ST_GeodesicLengthWGS84(ST_SetSRID(ST_LineString(array(ST_Point(longitude_of_center, 
latitude_of_center), 
ST_Point(longitude_of_point, latitude_of_point))), 4326)) <= 200;

Please, I need also is to get the distance between the choosen points and the center as part of my query result as a new colum DIST.


Solution

  • You can make a LineString from each chosen point paired with the center, then call GeodesicLengthWGS84 on each such LineString. It would be the same Length call as you have in the where clause, but also added to the column projections (so something like select *, ST_GeodesicLengthWGS834(...) from ....

    (disclosure: collaborator on Esri Spatial Framework for Hadoop)