4

I'm trying to convert multipolygon to in the right-hand format so that Leaflet can use it on the front end.

ogr2ogr -nln [target_table] -nlt PROMOTE_TO_MULTI -lco GEOMETRY_NAME=geom -lco FID=gid -lco RFC7946=YES -lco PRECISION=NO Pg:"dbname=[taget_db] host=localhost user=spatial_user port=5432" source_sub_counties.shp

Import is done but there is warning:

Warning 6: dataset Pg:dbname=[target_db} host=localhost user=spatial_user port=5432 does not support layer creation option RFC7946

How to fix this issue ?

Versions:

  • GDAL 3.4.1, released 2021/12/27
  • PostgresSQL version 14
  • Ubuntu Linux 22/04

1 Answer 1

6

The RFC7946=[YES/NO] option is a layer creation option of the GeoJSON driver https://gdal.org/drivers/vector/geojson.html. Other drivers do not have that creation option, including the PostGIS driver https://gdal.org/drivers/vector/pg.html.

In PostGIS the orientation of the rings can be controlled with the functions https://postgis.net/docs/ST_ForcePolygonCCW.html and https://postgis.net/docs/ST_ForcePolygonCW.html. The "CCW" stands for counter-clockwise orientation of the exterior ring, and "CW" stands for clockwise orientation of the exterior ring.

Please clarify how do you plan to use the PostGIS data in Leaflet.

3
  • pool.query("SELECT id, ST_AsGeojson(geom)::json as polygon, name FROM public.table_name");
    – matsukan
    Commented Feb 19 at 15:16
  • Frontend side : {subcounties && (<GeoJSON key='my-geojson' data={subcounties} style={styles} attribution='counties' />)}
    – matsukan
    Commented Feb 19 at 15:18
  • All this happens after ogr2ogr has done its job. See postgis.net/docs/ST_AsGeoJSON.html about the PostGIS side, including the hint about using ST_ForcePolygonCCW if needed.
    – user30184
    Commented Feb 19 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.