I have a MySQL table with 2 columns, id, a unique geometry id, and GeoJSON stored as a varchar, eg,

{"type": "Point", "coordinates": [116.4, 45.2, 11.1]}




I wish to store this data in PostGIS, and then I will run queries to check if a given lat/lon is in any of the geometries stored in the DB or the distances to them, etc.

If I use the geometry datatype I will have to specify the type as point, polygon etc, but I want all types in one column.

  • 3
    Geometries in PostGIS can also be defined to be of a general type "geometry".
    – user30184
    Commented Apr 27, 2015 at 5:19
  • I have a vague recollection that key word geometry/geography type and hstore type could be very useful for you. i'm not sure if psotgis support json column queries (select from x where json.key like 'something' ) but i recall that hstore should be "easy" solution for it Commented Apr 27, 2015 at 6:52
  • What version of Postgres/Postgis. There is a native binary JSON type, JSONB, since 9.1, that allows for indexing of JSON. You still might be better splitting the JSON up and inserting as real geometry types. Could you clarify what type of queries you will be running. Commented Apr 27, 2015 at 7:08
  • yes the general type "geometry" helped me for that I added 2 extensions 1) postgis 2) postgis_topology Also with every geoJson object I was bound to add this key_value pairs "crs":{"type":"name","properties":{"name":"EPSG:4326"}
    – sidd.k
    Commented Apr 27, 2015 at 14:02
  • If you have mixed srid in table you can use ST_SRID (postgis.net/docs/ST_SRID.html) to get correct srid for feature. Commented Apr 28, 2015 at 6:54

1 Answer 1


You can define your geometry column as a GeometryCollection. Then you can add whatever geometry type you want in each row.





geom geometry(GeometryCollection,4326)


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.