Project

General

Profile

Shapefiles » History » Version 2

« Previous - Version 2/4 (diff) - Next » - Current version
Philippe May, 04/11/2016 22:50


Shapefiles

Command line

Typical import:

shp2pgsql -s 32644 AV_wells_UTM44N.shp wells | psql -U avgis -d avgis -h server.gis.av

Note the srid 32644 (http://spatialreference.org/ref/epsg/wgs-84-utm-zone-44n/): it sets the geo reference system ID, which is not detected automatically, apparently. Shapefiles in the AV project use this coordinates system.

Postgres can use a file where passwords are stored ($HOME/.pgpass), it's handy to set it like so:

server.gis.av:5432:avgis:avgis:the_password

QGis

Qgis can be used to import Shapefiles to the database. It's dead easy, just drag and drop the files (from the Browser Panel -> Home/...) to the database connection.

However, it doesn't set the geometry features metadata to the proper SRID (32644 in our case), leading to difficulties fetching the proper coordinates.

One way around it is to force the geomety in the imported tables with the Postgis UpdateGeometrySRID function, like so:

psql -U avgis -d avgis -h server.gis.av -c "select UpdateGeometrySRID('public', 'wells', 'geom', 32644) ;"