[英]How to convert geometry string like “POLYGON ((32.5 39.2, 32.6 39.4 … ))” to GeoJSON in Javascript
我有像这样的字符串
POLYGON ((32.5 39.2, 32.6 39.4 .... ))
POINT (32.4 39.2)
使用 Leaflet,React 有没有办法将这些字符串转换为 GeoJSON,如:
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
},
"properties": {
"name": "Dinagat Islands"
}
}
在 JavaScript 中?
这些字符串称为 WKT ( https://en.wikipedia.org/wiki/Well-known_text_representation_of_geometry )。
那里有很多解析器: https://www.npmjs.com/search?q=wkt
“wellknown” 和 “wicket” 可以 output GeoJSON,可能还有其他模块也支持这个。
请注意,WKT 仅代表 GeoJSON 中的“几何”字段,“属性”字段的内容应该来自其他地方(例如,如果这是 CSV - 来自其他 CSV 列)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.