Shapefiles » History » Version 2
Version 1 (Philippe May, 04/11/2016 22:50) → Version 2/4 (Philippe May, 04/11/2016 22:50)
h1. Shapefiles
h2. Command line
Typical import:
<pre>
shp2pgsql -s 32644 AV_wells_UTM44N.shp wells | psql -U avgis -d avgis -h server.gis.av
</pre>
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:
<pre>
server.gis.av:5432:avgis:avgis:the_password
</pre>
h2. 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:
<pre>
psql -U avgis -d avgis -h server.gis.av -c "select UpdateGeometrySRID('public', 'wells', 'geom', 32644) ;"
</pre>
h2. Command line
Typical import:
<pre>
shp2pgsql -s 32644 AV_wells_UTM44N.shp wells | psql -U avgis -d avgis -h server.gis.av
</pre>
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:
<pre>
server.gis.av:5432:avgis:avgis:the_password
</pre>
h2. 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:
<pre>
psql -U avgis -d avgis -h server.gis.av -c "select UpdateGeometrySRID('public', 'wells', 'geom', 32644) ;"
</pre>