Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rkaneko/084237b2846839d35c1f565395c5a5fd to your computer and use it in GitHub Desktop.
Save rkaneko/084237b2846839d35c1f565395c5a5fd to your computer and use it in GitHub Desktop.
PostGIS query to convert FeatureCollection GeoJSON into MultiPolygon GeoJSON
WITH original AS (
SELECT
ST_Collect(ST_ShiftLongitude(ST_GeomFromGeoJSON(feat->>'geometry'))) geom
FROM (SELECT json_array_elements('HERE_IS_FEATURE_COLLECTION_GEOJSON'::json->'features') AS feat) AS f
)
SELECT ST_AsGeoJSON(o.geom) FROM original o LIMIT 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment