Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This question already has an answer here:

I try to store a polygon in GeoJSON format into my PostGIS table. Both are using the CRS EPSG:3857. This is how the polygon is defined. Note that I put in some whitespace to make it more readable.

{
    "type":"Polygon",
    "coordinates":[
        [-91.23046875,45.460130637921],
        [-79.8046875,49.837982453085],
        [-69.08203125,43.452918893555],
        [-88.2421875,32.694865977875],
        [-91.23046875,45.460130637921]
    ],
    "crs":{"type":"name","properties":{"name":"EPSG:3857"}}
}

To store that in my database I use the following SQL query.

INSERT INTO tablename (name, polygon)
VALUES ('name', ST_GeomFromGeoJSON('GeoJSON string comes here...'))

But for some reason the above query throws an error.

ERROR:  Geometry has Z dimension but column does not

What is wrong in my attempt?

share|improve this question

marked as duplicate by Devdatta Tengshe, iant May 16 '13 at 13:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
It seems to me that the problem is in your table, probably you have a z column in it. –  Gery May 16 '13 at 14:10

1 Answer 1

up vote 2 down vote accepted

I found the solution. The GeoJSON specification says that the coordinates of a polygon are an array of line strings. Therefore I had to wrap them with additional brackets.

{
    "type":"Polygon",
    "coordinates":
    [
        [
            [-91.23046875,45.460130637921],
            [-79.8046875,49.837982453085],
            [-69.08203125,43.452918893555],
            [-88.2421875,32.694865977875],
            [-91.23046875,45.460130637921]
        ]
    ],
    "crs":{"type":"name","properties":{"name":"EPSG:3857"}}
}
share|improve this answer

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