I need to insert a polygon from GeoJSON to my PostGIS table. This is how the SQL query looks like.
INSERT INTO tablename (name, polygon)
VALUES
(
'Name',
ST_GeomFromGeoJSON
(
{
"type":"Polygon",
"coordinates":[
[7.734375,51.835777520452],
[3.8671875,48.341646172375],
[7.20703125,43.580390855608],
[18.6328125,43.834526782237],
[17.9296875,50.289339253292],
[13.7109375,54.059387886624],
[7.734375,51.835777520452]
]
}
)
)
Unfortunately, I get an error message.
ERROR: Geometry SRID (0) does not match column SRID (3857)
The GeoJSON is already in the right reference system. But this isn't specified. How to specify the SRID in the GeoJSON? How have the GeoJSON to look like?
Update: When I wrap the geometry created by ST_GeomFromGeoJSON
with ST_SetSRID(..., 3857)
it throws another error. In my view it doesn't seem that the geometry has a Z dimension.
ERROR: Geometry has Z dimension but column does not