Shapfileæ件为ESRIå
¬å¸çæ件åå¨æ ¼å¼ï¼å¹¶ä¸å¾å°äºä¸ç广
æ³çæ¯æãShapfileæ ¼å¼æ¯ä¸ç§ç®åçï¼ç¨éææ´å
³ç³»çå½¢å¼åå¨å ä½ä½ç½®åå°çç¹å¾çå±æ§ä¿¡æ¯çæ ¼å¼ãè½ç¶GeoServeréç¨Shapfile
æ件å¯ä»¥å¿«éçå建ç½ä¸å°å¾æå¡ï¼ä½å®ç缺ç¹ç¡®å¾ææ¾ï¼
ãã1ãShapefileåªæ¯æä¸ä¸ªå¾å±ï¼å¨å®é
ä¸æ²¡ææä¹ã
ãã2ãç´æ¥ä¿ç¨SHPæ件ä¸å®å
¨ï¼Shapfileæ件å¾å®¹æ被ç
æ¯æå
¶ä»åå 误å é¤ã
ãã3ãGeoServerä¸ç¨Shapfileæ件ä½æ°æ®æºçæçæ¯å¾ä½çã
ãã4ãShapfileä¸çæ±åGeoServerä¸è½è§£æï¼ä¼åºç°ä¹±ç ã
ãã5ãæ°æ®åºå¯ä»¥æ¹ä¾¿ç对å°çä¿¡æ¯è¿è¡æ¥è¯¢ã
ç¨PostGIS管ç空é´æ°æ®
ããPostGISæ¯æGIST空é´ç´¢å¼ï¼éå½1ï¼ãè§èçªä½ï¼è½å¾å¤§çæé«å¤çæçã
ãã
OGCæ ¼å¼åªæä¾äºç»´çå ä½ä½ï¼ä¸ç¸å
³èçSRIDä»æªæ·±å
¥çç¨äºè¾å
¥è¾åºè¯·æ±ï¼PostGISæ¯æOpenGISç»ç»"Simple Features
for SQL"è§èæå®çææGIS对象åå½æ°ï¼å¹¶è¿è¡äºæ©å±ï¼æ ¼å¼æ¯EWKBãEWKTï¼å
¶ä¸å¢å äºå¯¹3DZï¼3DMå4D
åæ ç³»çæ¯æ(å½ç¶ä¸ç»´ãåç»´æ°æ®çOGCæ åè¿æªå®å
¨å¶å®)ï¼æ·±å
¥å¼è¿äºSRIDä¿¡æ¯ã
ãã空é´æ°æ®è¡¨ç»æï¼PostGISä¸åå¨ä¸¤ä¸ªå¿
éçå
æ°æ®è¡¨æ ¼ï¼ SPATIAL_REF_SYSï¼ç©ºé´åèè¡¨æ ¼ï¼ å GEOMETRY_COLUMNSï¼å ä½ä½å±æ§åï¼ï¼ä¸¤ä¸ªè¡¨ç¨äºåå¨ç©ºé´æ°æ®åºä½¿ç¨çåæ ç³»ç»æ°åIDåææ¬æè¿°ã
ããPostGISçshp2pgsqlå½ä»¤å¯ä»¥å°Shapfileç´æ¥å¯¼å
¥å°æ°æ®åºä¸ä¹å¯ä»¥å¯¼åºä¸ºSQLæ件ï¼æ¨èå
导åºä¸ºSQLæ件åå°æ¤æ件å¨SQLè¿è¡çªå£ä¸æ§è¡å¯å°æ°æ®å¯¼å
¥æ°æ®åºã代ç å¦ä¸ï¼
Shapfileå°SQLè¯å¥ï¼
ããshp2pgsql è·¯å¾/shpæ°æ®æ件å æ°å»ºçæ°æ®è¡¨å > è·¯å¾/SQLæ件å.sql
Shapfileç´æ¥å
¥åºï¼
ããshp2pgsql -c è·¯å¾/shpæ°æ®æ件å æ°å»ºçæ°æ®è¡¨å æ°æ®åºåï½psql -d æ°æ®åºå
举ä¾è¯´æï¼
ããå¦å°ä¸Shapfileæ件âc:/road.shpâ导å
¥å°æ°æ®è¡¨âroadâä¸ï¼æ°æ®åºä¸ºâsjzmapâã
ãã1ãè¿è¡âå½ä»¤æ示符âã
ãã2ãåæ¢è³PostgreSQLæ°æ®åºå®è£
ç®å½ä¸çbinç®å½ä¸ã
ãã3ãæ§è¡æ¤ç®å½ä¸çshp2pgsqlå½ä»¤ï¼âshp2pgsql c:/road.shp road > c:/road.sqlâã
ãã4ãå¦å°æ¤æ件ç´æ¥å¯¼å
¥æ°æ®åºï¼ä¸æ¨èï¼ï¼âshp2pgsql -c c:/road.shp road sjzmap | psql -d sjzmapâã
5ã使ç¨pgAdmin3 éæ©æ°æ®åºï¼å导å
¥è¡¨ã
注ï¼
-d
Drops the database table before creating a new table with the data in the Shape file.
-a
Appends data from the Shape file into the database table. Note that
to use this option to load multiple files, the files must have the same
attributes and same data types.
-c
Creates a new table and populates it from the Shape file. This is the default mode.
-p
Only produces the table creation SQL code, without adding any actual
data. This can be used if you need to completely separate the table
creation and data loading steps.
-D
Use the PostgreSQL "dump" format for the output data. This can be
combined with -a, -c and -d. It is much faster to load than the default
"insert" SQL format. Use this for very large data sets.
-s <SRID>
Creates and populates the geometry tables with the specified SRID.
-k
Keep identifiers' case (column, schema and attributes). Note that attributes in Shapefile are all UPPERCASE.
-i
Coerce all integers to standard 32-bit integers, do not create 64-bit
bigints, even if the DBF header signature appears to warrant it.
-I
Create a GiST index on the geometry column.
-w
Output WKT format, for use with older (0.x) versions of PostGIS. Note
that this will introduce coordinate drifts and will drop M values from
shapefiles.
-W <encoding>
Specify encoding of the input data (dbf file). When used, all
attributes of the dbf are converted from the specified encoding to UTF8.
The resulting SQL output will contain a SET CLIENT_ENCODING to UTF8
command, so that the backend will be able to reconvert from UTF8 to
whatever encoding the database is configured to use internally.
温馨提示:答案为网友推荐,仅供参考