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": 
"address": "N\u00e1dor u. 23.", "owner": "simplegeo", "postcode": "1051"}}


  • 4
    You should warn that your dataset is 2.2 GB. For making it more attractive to help you, could you prepare test data with just couple of features? That is well enough for testing.
    – user30184
    Dec 1 '15 at 6:45
  • added data format for reference. Dec 1 '15 at 7:03
  • 1
    How have you tried to import the data, and what is the error message?
    – til_b
    Dec 1 '15 at 7:46
  • GDAL reads that one feature fine. You can test it yourself by saving it on the disk and running ogrinfo -al sample.json. You should really tell what you did and how did it fail.
    – user30184
    Dec 1 '15 at 12:22
  • I executed: ogr2ogr -f "PostgreSQL" PG:"dbname=my_database user=postgres" "source.geojson" but I am getting error as: FAILURE Unable to open datasource `source.geojson' with the following drivers. (showing list of drivers) Dec 1 '15 at 18:24

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.)

  • 2
    I am getting error as : FAILURE Unable to open datasource `source.geojson' with the following drivers. (showing list of drivers). Dec 1 '15 at 18:22
  • That has to be the full path to your geojson Dec 1 '15 at 18:49
  • I added full path as well, still I am getting the same error. Dec 1 '15 at 18:50
  • 1
    gdal-bin is already installed in my system (ubuntu). Dec 1 '15 at 19:21
  • 2
    I'm not going to download 2GB to look, but are your features a feature collection? Dec 1 '15 at 21:06
./ogr2ogr -f "PostgreSQL" PG:"dbname=theDatabaseName user=postgres" "/Users/dev/Downloads/theGeometry.json" -where "name not like 'Whatever%'" -nln theFeatureName -overwrite

ogr2ogr displays a list of drivers when the file is not found. in that case just pass in the full path to the json file

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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