简体   繁体   中英

How to import gis shapefiles into postgis database programatically?

How can I import gis shapefiles into postgis database programatically using java ? I used a program named postgis shapefile import but now I want to do it in my java code.

The most common tool (one of several) is shp2pgsql , which comes with PostGIS. It is normally used from a command prompt, but can be used through Java's ProcessBuilder .

ProcessBuilder pb =
   new ProcessBuilder("/bin/sh", "-c", "shp2pgsql my.shp | psql -d mydb");
Process p = pb.start();

ogr2ogr is another commonly used tool to convert most geospatial vector formats to PostGIS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM