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

南笙酒味 提交于 2019-11-30 09:16:26

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);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!