简体   繁体   中英

st_contains in athena

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))  

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM