st_contains in athena

主宰稳场 提交于 2020-08-10 19:16:51

问题


the below code should return true but returns false. I tested in google maps and point lies in the polygon. I am not sure what is the issue here. I am running this code in Athena

select 
st_contains (st_polygon( 'POLYGON((54.8163815 24.9474831),
(54.9310513 24.8914383),
(55.0514856 24.8349286),
(55.1170345 24.9527804),
(55.1686306 25.0937019),
(55.3738202 25.1844963),
(55.3676957 25.3050482),
(55.2592057 25.3944044),
(54.8163815 24.9474831))'),st_point(55.163485,25.092776))  

回答1:


Here is the response I obtained from the Athena team:

The root cause is the string to create the polygon is in wrong format. If you run this query:

select st_geometry_to_text(st_polygon('POLYGON((54.8163815 24.9474831),
(54.9310513 24.8914383),
(55.0514856 24.8349286),
(55.1170345 24.9527804),
(55.1686306 25.0937019),
(55.3738202 25.1844963),
(55.3676957 25.3050482),
(55.2592057 25.3944044),
(54.8163815 24.9474831))'));

then the error message states: corrupted geometry

The correct format/syntax, according to the Well-Known Text (WKT) should be:

select st_contains('POLYGON(
(54.8163815 24.9474831,
54.9310513 24.8914383,
55.0514856 24.8349286,
55.1170345 24.9527804,
55.1686306 25.0937019,
55.3738202 25.1844963,
55.3676957 25.3050482,
55.2592057 25.3944044,
54.8163815 24.9474831))',
st_point(55.163485,25.092776));

and it will return true.



来源:https://stackoverflow.com/questions/62535666/st-contains-in-athena

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!