Вопрос

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top