Difference between revisions of "PostGIS function pgsql2shp"
From IMSMA Wiki
Line 30: | Line 30: | ||
{{Note | Any " inside the SQL statement needs to be escaped and therefore it is easier to refer to a SQL view that contains the columns and rows you would like to export.}} | {{Note | Any " inside the SQL statement needs to be escaped and therefore it is easier to refer to a SQL view that contains the columns and rows you would like to export.}} | ||
− | [[Image:Pgsql2shp.png| | + | [[Image:Pgsql2shp.png|600px|center]]<br/> |
<div align="center"> | <div align="center"> | ||
'' The number of rows exported will be shown when the export is done '' | '' The number of rows exported will be shown when the export is done '' |
Revision as of 13:12, 11 September 2018
The example below is using the staging area database. |
One of the geotables need to be included in the table/view that you are exporting:
- xx_point
- xx_polygon
- xx_polyline.
The mandatory column to include in the export is called shape
- Create a SQL view or use one of the existing GIS views
- Open the command / DOS prompt
- Go to C:\IMSMAng\pgsql\bin
- Run the command pgsql2shp with the following parameters
- -f the name of the resulting shape file
- -h host name
- if the Staging area database is on your computer than use localhost
- -u user
- use imsma
- -P password
- use password
- database name
- SQL view or table name
If you would like to export all rows then you refer to the SQL view/table by the name of it. If you would like to export only some rows then you need to add more SQL statements.
Any " inside the SQL statement needs to be escaped and therefore it is easier to refer to a SQL view that contains the columns and rows you would like to export. |
The number of rows exported will be shown when the export is done
Example: pgsql2shp -f land_polygon -h localhost -u imsma -P password staging " select * from haz_gis_poly where \"Status\" = 'Closed' "
If the Output shape type is Unknown then there is something wrong with the SQL view/table. Most likely the mandatory column shape is not included. |
|