使用配置单元列出半径内的所有点

6mzjoqzu  于 2021-06-28  发布在  Hive
关注(0)|答案(2)|浏览(526)

我有一张table如下:

  1. id_center|latitude_of_center|longitude_of_center|id_point|latitude_of_point|longitude_of_point

这张table有数百万行
我试图得到一个输出,它将显示每个id\u中心,哪个id\u点在半径为5英里的范围内,以及距离有多远,按降序排序。每一行都是完全填充的,所以每个id\u中心都在单独的行中有所有可能的id\u点。以下是我迄今为止尝试的结果,我只得到了空结果:

  1. hive> add jar /home/me/gis-tools-for-hadoop/samples/lib/esri-geometry-api.jar;
  2. Added [/home/me/gis-tools-for-hadoop/samples/lib/esri-geometry-api.jar] to class path
  3. Added resources: [/home/me/gis-tools-for-hadoop/samples/lib/esri-geometry-api.jar]
  4. hive> add jar /home/me/gis-tools-for-hadoop/samples/lib/spatial-sdk-hadoop.jar;
  5. Added [/home/me/gis-tools-for-hadoop/samples/lib/spatial-sdk-hadoop.jar] to class path
  6. Added resources: [/home/me/gis-tools-for-hadoop/samples/lib/spatial-sdk-hadoop.jar]
  7. hive> create temporary function ST_GeodesicLengthWGS84 AS 'com.esri.hadoop.hive.ST_GeodesicLengthWGS84';
  8. OK
  9. Time taken: 0.014 seconds
  10. hive> create temporary function ST_SetSRID AS 'com.esri.hadoop.hive.ST_SetSRID';
  11. OK
  12. Time taken: 0.008 seconds
  13. hive> create temporary function ST_LineString AS 'com.esri.hadoop.hive.ST_LineString';
  14. SELECT * FROM mytable WHERE ST_GeodesicLengthWGS84(ST_SetSRID(ST_LineString(latitude_of_center, longitude_of_center, latitude_of_point, longitude_of_point), 4326)) <= 8046.72
2mbi3lxu

2mbi3lxu1#

我曾经 ST_Point 内部 ST_LineString 在做类似的工作时。在文档中选中此选项。就你而言:

  1. SELECT * FROM mytable
  2. 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)) <= 8046.72;
rmbxnbpk

rmbxnbpk2#

对于st_linestring,首先需要经度,然后是纬度-(x,y)顺序(如gis se所述https://gis.stackexchange.com/questions/178950/hive-gis-st-geodesiclengthwgs84-not-returning-expected-distance)

相关问题