问题描述
我有很多需要手动绘制然后再获取地理坐标的多边形.我需要以GeoJSON格式获取绘制的多边形的坐标.
I have many polygons that need to be drawn manually and then get geo-coordinates.I need to get the coordinates of the drawn polygons in GeoJSON format.
以这种格式:
"{"type":"MultiPolygon","coordinates":[[[[37.4653933,55.3959159]...}"
"{"type":"Polygon","coordinates":[[[37.475738525390625,55.41420507450017]...}"
或者在此:
"{"type":"GeometryCollection","geometries":[{"type":"Polygon","coordinates":[[[-98.0419921875,39.027718840211605]...}]}"
我在 http://geojson.io/处绘制多边形.但是从此站点,我只能以FeatureCollection类型的格式获取数据.我找到了另一个网站- https://rodic.fr/blog/online-conversion-between-geometric-formats/,可以在其上转换为GeoJSON格式,但是此站点只能转换GeometryCollection类型.
I draw polygons at http://geojson.io/.But from this site I can only get data in the format with the FeatureCollection type.I found another site - https://rodic.fr/blog/online-conversion-between-geometric-formats/, on which I can convert to GeoJSON format, but this site can only convert type GeometryCollection.
我找不到如何将FeatureCollection转换为GeometryCollection或MultiPolygon或Polygon的方法.
I cannot find how to convert FeatureCollection to GeometryCollection or MultiPolygon or to Polygon.
如何解决?多谢!
推荐答案
要获取geojson格式的坐标,可以使用以下代码段:
To get the coordinates in the geojson format, you can use the following snippet:
WITH geojson_featurecollection AS (
SELECT ''::json AS fc
)
SELECT (json_array_elements(fc->'features'))->>'geometry'
FROM geojson_featurecollection;
,在其中粘贴整个FeatureCollection定义(编辑后来自 http://geojson.io 网站))内的引号
in which you paste your entire FeatureCollection definition (coming from the http://geojson.io website after your edits) inside of the quotes
这篇关于如何将FeatureCollection转换为GeometryCollection或MultiPolygon?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!