[GIS] Import GeoJSON into PostGIS

geojsonimportmongodbpostgis

I want to import GeoJSON avaliable in the following dump into PostGIS but I am not able to import it. I already imported geousa data available in this public dump into MongoDB smoothly. Let me know is there a way to import this data directly or through MongoDB?

As this data is huge please check following data:

{"geometry": {"type": "Point", "coordinates": [19.056792, 47.490894]}, "type": "Feature",
"id": "SG_1iYphlxn9BSHyGrpv1aXKc_47.490894_19.056792@1308163237",
"properties": {"website": "http://mito.hu", "city": "Budapest",
"name": "Mito Europe", "tags": ["online", "communication", "design",
"branding", "development", "mito"], "country": "HU", "classifiers":
[{"category": "Professional", "type": "Services", "subcategory": "Advertising"}], "href": 
"http://api.simplegeo.com/1.0/features/SG_1iYphlxn9BSHyGrpv1aXKc_47.490894_19.056792@1308163237.json",
"address": "N\u00e1dor u. 23.", "owner": "simplegeo", "postcode": "1051"}}

http://s3.amazonaws.com/simplegeo-public/places_dump_20110628.zip

Best Answer

You can use PostGIS's ST_GeomFromGeoJSON to bring in just the geometry part of the GeoJSON.

Better yet, you can use ogr2ogr to import the entire JSON document:

ogr2ogr -f "PostgreSQL" PG:"dbname=my_database user=postgres" "source_data.json" -nln destination_table -append

(I haven't tested this with your data, add a comment if you have issues.)

Related Question