[GIS] Importing GeoJSON to PostGIS with ogr2ogr and keeping geometry

geojsonogr2ogrpostgis

I have a .geojson file with line types that I'm trying to import into PostGIS with ogr2ogr. Following answers to similar questions on here, I tried the following:

ogr2ogr -f PostgreSQL PG:"dbname=gis user=alex" roads.geojson -nln roads

Using pgAdmin I can see that the roads table was created and the data imported, but when I go to add the table in QGIS in shows up as NoGeometry. I've tried adding -nlt with LINESTRING, MULTILINESTRING, and GEOMETRY, but no luck.

I'm new to PostGIS and ogr2ogr–can someone please shed some light on what I might be doing wrong?

Best Answer

Newbie mistake on my part. The PostGIS extension has to be enabled for each database before it can be used by running CREATE EXTENSION postgis;

Related Question