I would like to use gdal_polygonize and gdalinfo in java. This site says: "Note that OSGeo4W includes a gdal-java package and a Java runtime making it fairly easily to build local Java applications using GDAL." But how?
1 Answer
You can see the source code for a gdalinfo java implementation here - https://svn.osgeo.org/gdal/trunk/gdal/swig/java/apps/gdalinfo.java
The polygonize function should be available in the java bindings, you may look at the source of gdal_polygonize.py to see how it's used - http://svn.osgeo.org/gdal/trunk/gdal/swig/python/scripts/gdal_polygonize.py
-
thanks that looks promising. I included gdal-1.10.1.jar and created gdalinfo.java. I also configured eclipse according to this site but there is an error when i try to run it: Native library load failed. java.lang.UnsatisfiedLinkError: no gdaljni in java.library.path Exception in thread "main" java.lang.UnsatisfiedLinkError: org.gdal.gdal.gdalJNI.AllRegister()V Jan 29, 2015 at 11:30
-
1
-
Ok so you mean I have to put them in the environment variables in sytem properties and not eclipse right? "...dir containing the gdal dlls to PATH" wich dlls? I have some in gdal/swig/java (like gdaljni.dll and ogrjni.dll) and some in OSGeo4W64\bin\gdalplugins (like gdal_GEOR.dll). Tried both and still got the same error. For GDAL_DATA I have OSGeo4W64\share\gdal and for GDAL_DRIVER_PATH OSGeo4W64\bin\gdalplugins ..The gdal.jar file I included into the build path of my eclipse-project is the bin\gdal\java of a download from this site. Jan 29, 2015 at 23:35
-
1Java needs to be able to find the native binaries, not just the jar. Here are some linux instructions, replace references to "export LD_LIBRARY_PATH etc..." with "SET PATH=etc...;%PATH%" from the command line, or set via the Windows environment variables GUI. Not sure about Eclipse, I don't use it, but you should be able to set up a run configuration with the appropriate variables.– user2856Jan 30, 2015 at 7:12
-