Postgresql 如何将FeatureCollection转换为GeometryCollection或MultiPolygon?
我有许多多边形需要手动绘制,然后获得地理坐标。 我需要以GeoJSON格式获得绘制多边形的坐标 以这种格式:Postgresql 如何将FeatureCollection转换为GeometryCollection或MultiPolygon?,postgresql,postgis,geojson,Postgresql,Postgis,Geojson,我有许多多边形需要手动绘制,然后获得地理坐标。 我需要以GeoJSON格式获得绘制多边形的坐标 以这种格式: "{"type":"MultiPolygon","coordinates":[[[[37.4653933,55.3959159]...}" "{"type":"Polygon","coordinates":[[[37.475738525390625,55.41420507450017]...}" 或在这方面: "{"type":"GeometryCollection","geometr
"{"type":"MultiPolygon","coordinates":[[[[37.4653933,55.3959159]...}"
"{"type":"Polygon","coordinates":[[[37.475738525390625,55.41420507450017]...}"
或在这方面:
"{"type":"GeometryCollection","geometries":[{"type":"Polygon","coordinates":[[[-98.0419921875,39.027718840211605]...}]}"
我在地图上画多边形。
但从这个网站上,我只能获得FeatureCollection类型格式的数据。
我找到了另一个站点-,在该站点上我可以转换为GeoJSON格式,但该站点只能转换类型GeometryCollection
我找不到如何将FeatureCollection转换为GeometryCollection或MultiPolygon或多边形
如何解决?
很多thx 要获取geojson格式的坐标,可以使用以下代码段:
WITH geojson_featurecollection AS (
SELECT ''::json AS fc
)
SELECT (json_array_elements(fc->'features'))->>'geometry'
FROM geojson_featurecollection;
在其中,您可以将整个FeatureCollection定义(编辑后来自网站)粘贴到引号中是!它的工作完美!!)祝你圣诞快乐我找到了另一个要转换为多重多边形的代码。我将测试这两个代码。再给你一个thx!)<代码>选择ST_AsText(ST_Collect(ST_GeomFromGeoJSON(专长->>'geometry')))作为f(选择json_数组元素('PUT_HERE'::json->'features')代码>