Difference between revisions of "PostGIS function pgsql2shp"

From IMSMA Wiki
Jump to: navigation, search
(Created page with "One of the geotables need to be included in the table/view that you are exporting and the mandatory column called ''shape''. # Create a SQL view or use one of the existing GI...")
 
Line 1: Line 1:
One of the geotables need to be included in the table/view that you are exporting and the mandatory column called ''shape''.
+
One of the geotables need to be included in the table/view that you are exporting and the mandatory column is called ''shape''.
  
 
# Create a SQL view or use one of the existing GIS views
 
# Create a SQL view or use one of the existing GIS views
Line 5: Line 5:
 
# Go to ''C:\IMSMAng\pgsql\bin''
 
# Go to ''C:\IMSMAng\pgsql\bin''
 
# Run the command ''pgsql2shp'' with the following parameters
 
# Run the command ''pgsql2shp'' with the following parameters
: -f the name of the resulting shape file
+
:: -f the name of the resulting shape file
: -h host name If the Staging area database is on your computer than use ''localhost''
+
:: -h host name If the Staging area database is on your computer than use ''localhost''
: -u user Use ''imsma''
+
:: -u user Use ''imsma''
: -P password Use ''password
+
:: -P password Use ''password
: database name
+
:: database name
: SQL view or table name You may refer to it by the name of if you would like to export all rows OR specify the SQL statement
+
:: SQL view or table name You may refer to it by the name of if you would like to export all rows OR specify the SQL statement
  
 
{{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.}}
  
pgsql2shp -f shape_name -h localhost -u imsma -P password staging
+
[[Image:Pgsql2shp.png|700px|center]]<br/>
"select * from xxx"
+
<div align="center">
 
+
'' The number of rows exported witll be shown when the export is done ''
 +
</div>
 +
Example: pgsql2shp -f land_polygon -h localhost -u imsma -P password staging " select * from haz_gis_poly where \"Status\" = 'Closed' "
  
 
{{NavBox AGOL Extension}}
 
{{NavBox AGOL Extension}}
 
[[Category:PEW]]
 
[[Category:PEW]]

Revision as of 08:56, 29 August 2017

One of the geotables need to be included in the table/view that you are exporting and the mandatory column is called shape.

  1. Create a SQL view or use one of the existing GIS views
  2. Open the command / DOS prompt
  3. Go to C:\IMSMAng\pgsql\bin
  4. 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 You may refer to it by the name of if you would like to export all rows OR specify the SQL statement
Note.jpg 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.
Pgsql2shp.png

The number of rows exported witll 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' "