[gdal-dev] Problems loading swedish climate data to PostGIS

Jeff McKenna jmckenna at gatewaygeomatics.com
Tue Jun 23 05:46:18 PDT 2020


Hi Thiemo!

I have downloaded your data, to hopefully show you how I would tackle this.

First thing is to take this in very small steps, to confirm along the 
way, otherwise you jump to ogr2ogr without confirming that it is even 
possible on your system - in other words, live by *ogrinfo*, ogrinfo is 
your friend, and only move to ogr2ogr once you have ogrinfo happy, and 
then later use ogrinfo again for confirmation.

Here are my notes, I've made comments with the # symbol, and I should 
also mention that I am testing on Windows, with MS4W, so sometimes the 
exact command may slightly change (such as a single quote instead of a 
double quote in a command, on Linux systems) :

create database
---------------

#must first create an empty db (named 'scid' here), and load the PostGIS 
extension
createdb -U postgres -p 5436 -E UTF8 scid
psql -U postgres -d scid -p 5436 -c "CREATE EXTENSION postgis;"
psql -U postgres -d scid -p 5436 -c "CREATE EXTENSION postgis_topology;"

ogrinfo
-------

#verify that your local GDAL/OGR is built with PostGIS and FileGDB support
ogrinfo --formats

     PostgreSQL -vector- (rw+): PostgreSQL/PostGIS
     MySQL -vector- (rw+): MySQL
     OpenFileGDB -vector- (rov): ESRI FileGDB
     XPlane -vector- (rov): X-Plane/Flightgear aeronautical data
     DXF -vector- (rw+v): AutoCAD DXF

#connect to your new database (see params for the PG driver at 
https://gdal.org/drivers/vector/pg.html )
ogrinfo PG:"host=localhost user=postgres password=postgres port=5436 
dbname=scid"

   INFO: Open of `PG:host=localhost user=postgres password=postgres 
port=5436 dbname=scid'
       using driver `PostgreSQL' successful.

#we're in business, no errors, yet no spatial tables listed yet, because 
there is none

#examine the file geodatabase
ogrinfo SCID_v4.0.gdb

INFO: Open of `SCID_v4.0.gdb'
       using driver `OpenFileGDB' successful.

#in my case, MS4W uses the 'OpenFileGDB' driver, but the 'FileGDB' 
driver is also possible

#356 layers should be listed there, with their layer names.  I'll use 
the last layer listed in the long list:

    356: HBVSv_MLSM_rcp85_ensembleMax_abs (Multi Polygon)

#so the layer name is 'HBVSv_MLSM_rcp85_ensembleMax_abs'

#examine the single layer through OGR/GDAL
ogrinfo SCID_v4.0.gdb HBVSv_MLSM_rcp85_ensembleMax_abs -summary

   - lists that there are 1103 features in that layer
   - EPSG (projection): https://epsg.io/3006

ogr2ogr
-------

#now you are ready to use ogr2ogr to bring the FileGDB layer into your 
empty PG/PostGIS database
ogr2ogr -f PostgreSQL PG:"host=localhost user=postgres password=postgres 
port=5436 dbname=scid" SCID_v4.0.gdb HBVSv_MLSM_rcp85_ensembleMax_abs

ogrinfo
-------

#use ogrinfo to confirm that the new spatial layer exists in your PG 
database
ogrinfo PG:"host=localhost user=postgres password=postgres port=5436 
dbname=scid"

  - should list your new layer 'hbvsv_mlsm_rcp85_ensemblemax_abs'

#examine your new layer
ogrinfo PG:"host=localhost user=postgres password=postgres port=5436 
dbname=scid" hbvsv_mlsm_rcp85_ensemblemax_abs -summary



Hope this helps.  Welcome to the FOSS4G community!

-jeff


-- 
Jeff McKenna
MapServer Consulting and Training Services
co-founder of FOSS4G
http://gatewaygeo.com/




On 2020-06-23 4:27 a.m., Thiemo Kellner wrote:
> Hi
> 
> I am new to spacial data processing. For a project of mine I try to load 
> swedish climate data in to my PostGIS installation running/using an 
> openSUSE Tumbleweed installation.
> 




More information about the gdal-dev mailing list