SHP導入POSTGIS數據庫sql
引用
直接導入數據庫 shp2pgsql -I -s 2437 -W GBK shop_point.shp public.ntable | psql -U postgres -w -d jwsz 導出sql再導入數據庫 shp2pgsql -s "2437" -W "GBK" -I D:\shop_point.shp newTable > D:\shop_point.sql psql -U postgres -f D:/shop_point.sql jwsz -P 123456
POSTGIS數據庫導出SHP:生成shp數據 //windows導出亂碼解決辦法:在環境變量中設置 PGCLIENTENCODING=GBK或PGCLIENTENCODING=GB18030,而後執行pgsql2shp,導出的shape文件中,屬性數據編碼正確是GBK的,沒有顯示亂碼。數據庫
引用
pgsql2shp -f shop_point -h localhost -u postgres -P 123456 jwsz public.shop_point pgsql2shp -g the_geom -f D:\shp.shp -u postgres -P 123456 -h 127.0.0.1 jwsz "select the_geom,name from shop_point" pgsql2shp -f shop_point -h localhost -u postgres -P 123456 jwsz "select the_geom,name from shop_point"
引用
@echo -d 刪除現有的表,並從新建立進行插入 @echo -a 向現有的表中插入,表必須存在 @echo -c 建立表並進行插入 @echo -p 只進行表的建立
shp2pgsql -s 4326 -W GBK CheckWell_point.shp public.CheckWell_point>CheckWell_point.sql
shp2pgsql -s 4326 -W GBK CheckWell_point.shp public.CheckWell_point psql -U postgres -w -d jwsz
@echo 導入 shp2pgsql -s 4326 -a -W GBK CheckWell_point.shp public.CheckWell_point>CheckWell_point.sql psql -U postgres -w -d jwsz -f CheckWell_point.sql -e @echo 導出 pgsql2shp.exe -f CheckWell_point -P 123456 -u postgres jwsz public.CheckWell_point
@echo 刪除並更新 點數據 shp2pgsql -s 4326 -d -W GBK CheckWell_point.shp public.CheckWell_point|psql -U postgres -w -d jwsz @echo 嘗試建立 線數據 shp2pgsql -s 4326 -p -W GBK CableLine_polyline.shp public.CableLine_polyline|psql -U postgres -w -d jwsz @echo 數據追加 線數據 shp2pgsql -s 4326 -a -W GBK CableLine_polyline.shp public.CableLine_polyline|psql -U postgres -w -d jwsz
@echo 嘗試建立 面數據 shp2pgsql -s 4326 -p -W GBK Bridge_region.shp public.Bridge_region|psql -U postgres -w -d jwsz @echo 數據追加 面數據 shp2pgsql -s 4326 -a -W GBK Bridge_region.shp public.Bridge_region|psql -U postgres -w -d jwsz pause
shp2pgsql命令相關參數windows
引用
RCSID: $Id: shp2pgsql-core.h 5983 2010-09-19 11:27:05Z mcayland $ RELEASE: 1.5 USE_GEOS=1 USE_PROJ=1 USE_STATS=1 USAGE: shp2pgsql [<options>] <shapefile> [<schema>.]<table> OPTIONS: -s <srid> Set the SRID field. Defaults to -1. (-d|a|c|p) These are mutually exclusive options: -d Drops the table, then recreates it and populates it with current shape file data. -a Appends shape file into current table, must be exactly the same table schema. -c Creates a new table and populates it, this is the default if you do not specify any options. -p Prepare mode, only creates the table. -g <geocolumn> Specify the name of the geometry/geography column (mostly useful in append mode). -D Use postgresql dump format (defaults to SQL insert statments. -G Use geography type (requires lon/lat data). -k Keep postgresql identifiers case. -i Use int4 type for all integer dbf fields. -I Create a spatial index on the geocolumn. -S Generate simple geometries instead of MULTI geometries. -W <encoding> Specify the character encoding of Shape's attribute column. (default : "WINDOWS-1252") -N <policy> NULL geometries handling policy (insert*,skip,abort) -n Only import DBF file. -? Display this help screen.
pgsql2shp命令相關參數app
引用
RCSID: $Id: pgsql2shp.c 5451 2010-03-22 19:38:40Z pramsey $ RELEASE: 1.5 USE_GEOS=1 USE_PROJ=1 USE_STATS=1 USAGE: pgsql2shp [<options>] <database> [<schema>.]<table> pgsql2shp [<options>] <database> <query>
OPTIONS: -f <filename> Use this option to specify the name of the file to create. -h <host> Allows you to specify connection to a database on a machine other than the default. -p <port> Allows you to specify a database port other than the default. -P <password> Connect to the database with the specified password. -u <user> Connect to the database as the specified user. -g <geometry_column> Specify the geometry column to be exported. -b Use a binary cursor. -r Raw mode. Do not assume table has been created by the loader. This would not unescape attribute names and will not skip the 'gid' attribute. -k Keep postgresql identifiers case. -? Display this help screen. ide