2

I am using following ogr2ogr command to import GeoJson data to Postgres DB. The command runs successfully but the geometry column is null.

ogr2ogr -f PostgreSQL PG:"dbname=test user=postgres password=test" sample3.geojson -nln test.sample3

The geojson file is big so putting some starting lines.

{ "type": "FeatureCollection", "properties": {
"bounds": "0.000001,0.000000,6.343452,51.486215",
"center": "3.779297,51.013722,11",
"description": "sample3.mbtiles",
"format": "pbf",
"json": "{\"vector_layers\": [ { \"id\": \"motorwaygeojson\", \"description\": \"\", \"minzoom\": 11, \"maxzoom\": 11, \"fields\": {} } ],\"tilestats\": {\"layerCount\": 1,\"layers\": [{\"layer\": \"motorwaygeojson\",\"count\": 21144,\"geometry\": \"LineString\",\"attributeCount\": 0,\"attributes\": []}]}}",
"maxzoom": "11",
"minzoom": "11",
"name": "sample3.mbtiles",
"type": "overlay",
"version": "2"
}, "features": [
{ "type": "FeatureCollection", "properties": { "zoom": 11, "x": 1023, "y": 1024 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "motorwaygeojson", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": {  }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000043 ], [ 0.000000, 0.000000 ], [ 0.000000, 0.000043 ] ] } }
] }
] }
,
{ "type": "FeatureCollection", "properties": { "zoom": 11, "x": 1024, "y": 1024 }, "features": [
{ "type": "FeatureCollection", "properties": { "layer": "motorwaygeojson", "version": 2, "extent": 4096 }, "features": [
{ "type": "Feature", "properties": {  }, "geometry": { "type": "LineString", "coordinates": [ [ 0.000000, 0.000043 ], [ 0.000000, 0.000000 ], [ 0.000000, 0.000043 ] ] } }
] }
] }

As you can see I have nested FeatureCollections, so what needs to be done to handle this scenario?

My postgres version is 9.3 and gdal version is 2.2.1

  • Does ogrinfo -so -al sample3.geojson show that it finds the geometry attribute? – user30184 Oct 24 '17 at 12:30
  • After using ogrinfo command i am getting "ERROR 1: Invalid Feature object. Missing 'geometry' member". But as you can see in geojson file geometry is there. – Ajinkya Oct 25 '17 at 3:42

Your Answer

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

Browse other questions tagged or ask your own question.