Shapefiles » History » Version 4
Philippe May, 04/11/2016 23:12
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 | 4 | Philippe May | The "-s 32644" parameter sets the geo reference system ID, which is not detected automatically, apparently. Shapefiles in the AV project use 32644 (http://spatialreference.org/ref/epsg/wgs-84-utm-zone-44n/) as the 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 | 3 | Philippe May | However, there are 2 issues: |
23 | 1 | Philippe May | |
24 | 3 | Philippe May | 1. it doesn't set the geometry features metadata to the proper SRID (32644 in our case), leading to difficulties fetching the proper coordinates. |
25 | 3 | Philippe May | |
26 | 1 | Philippe May | One way around it is to force the geomety in the imported tables with the Postgis UpdateGeometrySRID function, like so: |
27 | 1 | Philippe May | <pre> |
28 | 1 | Philippe May | psql -U avgis -d avgis -h server.gis.av -c "select UpdateGeometrySRID('public', 'wells', 'geom', 32644) ;" |
29 | 1 | Philippe May | </pre> |
30 | 3 | Philippe May | |
31 | 3 | Philippe May | 2. It imports geometries as "multi", aka points are defined as MultiPoint. Not sure at this early stage (of writing) what are the consequences, Gisaf assumes that single points are stored as "Point". |