简体   繁体   English

如何以编程方式将gis shapefile导入postgis数据库?

[英]How to import gis shapefiles into postgis database programatically?

How can I import gis shapefiles into postgis database programatically using java ? 如何使用java以编程方式将gis shapefile导入postgis数据库? I used a program named postgis shapefile import but now I want to do it in my java code. 我使用了一个名为postgis shapefile import的程序,但现在我想在我的java代码中执行它。

The most common tool (one of several) is shp2pgsql , which comes with PostGIS. 最常用的工具(几种中的一种)是shp2pgsql ,它附带PostGIS。 It is normally used from a command prompt, but can be used through Java's ProcessBuilder . 它通常在命令提示符下使用,但可以通过Java的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. ogr2ogr是另一种将大多数地理空间矢量格式转换为PostGIS的常用工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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