Project

General

Profile

Shapefiles » History » Version 2

Philippe May, 04/11/2016 22:50

1 1 Philippe May
h1. Shapefiles
2 1 Philippe May
3 2 Philippe May
h2. Command line
4 2 Philippe May
5 2 Philippe May
Typical import:
6 2 Philippe May
7 2 Philippe May
<pre>
8 2 Philippe May
shp2pgsql -s 32644 AV_wells_UTM44N.shp wells | psql -U avgis -d avgis -h server.gis.av
9 2 Philippe May
</pre>
10 2 Philippe May
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.
11 2 Philippe May
12 2 Philippe May
Postgres can use a file where passwords are stored ($HOME/.pgpass), it's handy to set it like so:
13 2 Philippe May
<pre>
14 2 Philippe May
server.gis.av:5432:avgis:avgis:the_password
15 2 Philippe May
</pre>
16 2 Philippe May
17 2 Philippe May
18 1 Philippe May
h2. QGis
19 1 Philippe May
20 1 Philippe May
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.
21 1 Philippe May
22 1 Philippe May
However, it doesn't set the geometry features metadata to the proper SRID (32644 in our case), leading to difficulties fetching the proper coordinates.
23 1 Philippe May
24 1 Philippe May
One way around it is to force the geomety in the imported tables with the Postgis UpdateGeometrySRID function, like so:
25 1 Philippe May
<pre>
26 1 Philippe May
psql -U avgis -d avgis -h server.gis.av -c "select UpdateGeometrySRID('public', 'wells', 'geom', 32644) ;"
27 1 Philippe May
</pre>