[英]Point in Polygon: Invalid GIS data provided to function st_within
I'm trying to determine if a given point is within a polygon through MySQL.我正在尝试通过 MySQL 确定给定点是否在多边形内。 I have setup a table called 'municipalities' with the following columns:我已经设置了一个名为“市政”的表,其中包含以下列:
| column | type |
|----------|---------|
| id | int |
| name | varchar |
| location | polygon |
I have imported a bunch of rows and now I'm trying to find a row where a given point is within the polygon.我已经导入了一堆行,现在我试图找到一个给定点在多边形内的行。 I'm using this query:我正在使用这个查询:
SELECT * FROM municipalities
WHERE st_contains(
location,
ST_GEOMFROMTEXT('POINT(50.849243 5.690800)')
);
Unfortunately, this results in an error: "Invalid GIS data provided to function st_within."不幸的是,这会导致错误: “提供给函数 st_within 的 GIS 数据无效。” . .
I'm completely lost as to why I'm getting this error.我完全不知道为什么我会收到这个错误。 I'm starting to think that the location column might contain faulty data, but I'm not sure how to check for that.我开始认为位置列可能包含错误数据,但我不确定如何检查。
Can anyone provide some insight into why this query is failing?任何人都可以提供一些有关此查询失败原因的见解吗?
Note: I'm using MySQL 5.7.22注意:我使用的是 MySQL 5.7.22
You may need to specify the EPSG of your point.您可能需要指定点的 EPSG。
ST_GeomFromText('POINT(45 90)', 4326);
Make sure that's in the same EPSG of your location data EPSG.确保它与您的位置数据 EPSG 位于同一 EPSG。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.