How to run GDAL (ogr2ogr) in Java to convert Shapefiles to GeoJSON

前端 未结 1 412
天涯浪人
天涯浪人 2020-12-31 15:59

I\'m a beginner at programming and get pretty confused when trying to use external libraries. I have my maps in shapefiles that I convert to GeoJSON using the website Mapsha

相关标签:
1条回答
  • 2020-12-31 16:38

    First you need to install the Java Bindings (see here at the bottom). Than download the ogr2ogr.java from here (scroll down -> download original format -> put it into your project folder). Than it gets quite easy. You just cann call ogr2ogr.java's main method. ogr2ogr -f GeoJSON -t_srs crs:84 [name].geojson [name].shp :

    String[] cmd = {"-t_srs", "CRS:84", "-f", "GeoJSON","[name].geojson","[name].shp"};
    
    ogr2ogr.main(cmd);
    
    0 讨论(0)
提交回复
热议问题