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

Thiemo Kellner thiemo at gelassene-pferde.biz
Tue Jun 23 13:35:15 PDT 2020


Hi Jeff

Thank you for sharing your steps. I tried to follow them and had an  
insight though I am still stuck. I noticed that I was passing the gdb  
file within the unzipped folder to ogr2ogr whereas you passed the  
folder path. Switching to your pattern it looks as follows.

thiemo @ thiemos-toshi /mnt/schweden % ogrinfo --formats | grep -i postg
   PostgreSQL -vector- (rw+): PostgreSQL/PostGIS
   PGDUMP -vector- (w+v): PostgreSQL SQL dump
# PostGIS capabilities of ogrinfo proven

thiemo @ thiemos-toshi /mnt/schweden % ogrinfo  
PG:"host='/var/run/postgresql' port='6543' dbname='sverige'  
user='sverige'"
INFO: Open of `PG:host='/var/run/postgresql' port='6543'  
dbname='sverige' user='sverige''
       using driver `PostgreSQL' successful.
1: tiger.county (Multi Polygon)
2: tiger.state (Multi Polygon)
...
# Connection to PostGIS works

thiemo @ thiemos-toshi /mnt/schweden % ogrinfo SCID_v4.0.gdb
INFO: Open of `SCID_v4.0.gdb'
       using driver `OpenFileGDB' successful.
1: HBVSv_intrans_HQloc100_rcp45_ensembleMean_diffPerc (Multi Polygon)
2: HBVSv_intrans_HQloc100_rcp85_ensembleMean_diffPerc (Multi Polygon)
...
# Proven to be able to read the gdb file(s)

thiemo @ thiemos-toshi /mnt/schweden % ogrinfo SCID_v4.0.gdb  
HBVSv_intrans_HQloc100_rcp85_ensembleMean_diffPerc -summary
INFO: Open of `SCID_v4.0.gdb'
       using driver `OpenFileGDB' successful.

Layer name: HBVSv_intrans_HQloc100_rcp85_ensembleMean_diffPerc
Geometry: Multi Polygon
Feature Count: 1103
...
# Proven to be able to access a specific layer in the gdb

thiemo @ thiemos-toshi /mnt/schweden % ogr2ogr –f "PostgreSQL"  
-overwrite –progress --config PG_USE_COPY YES  
PG:"host='/var/run/postgresql' port='5432' dbname='sverige'  
user='sverige'" SCID_v4.0.gdb  
HBVSv_intrans_HQloc100_rcp85_ensembleMean_diffPerc
FAILURE:
Unable to open datasource `PostgreSQL' with the following drivers.
   -> `PCIDSK'
...
# UNABLE TO USE ogr2ogr TO WRITE DATA TO MY PostGIS

thiemo @ thiemos-toshi /mnt/schweden :-( % ogr2ogr –f "ESRI Shapefile"  
test.shp SCID_v4.0.gdb/gdb.shp SCID_v4.0.gdb  
HBVSv_intrans_HQloc100_rcp85_ensembleMean_diffPerc
FAILURE:
Unable to open datasource `ESRI Shapefile' with the following drivers.
   -> `PCIDSK'
...
# To me it seems that I am not able to use ogr2ogr eventhough I can  
ogrinfo shape files
thiemo @ thiemos-toshi /mnt/schweden % ogrinfo --formats | grep -i esri
   ESRI Shapefile -vector- (rw+v): ESRI Shapefile
   ESRIJSON -vector- (rov): ESRIJSON
   PGeo -vector- (ro): ESRI Personal GeoDatabase
   OpenFileGDB -vector- (rov): ESRI FileGDB

I am pritty lost.

Kind regards

Thiemo

Quoting Jeff McKenna <jmckenna at gatewaygeomatics.com>:

> 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.
>>
>
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/gdal-dev



-- 
S/MIME Public Key: https://oc.gelassene-pferde.biz/index.php/s/eJuAUFONag6ofnH
Signal (Safer than WhatsApp): +49 1578 7723737
Handys: +41 78 947 36 21 | +49 1578 772 37 37
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4001 bytes
Desc: S/MIME Signature
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20200623/9dd9931b/attachment.bin>


More information about the gdal-dev mailing list