Quantcast

[gdal-dev] GDAL and OGR utilities as library functions?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[gdal-dev] GDAL and OGR utilities as library functions?

Vlad
Greetings:
Referencing this blog post http://erouault.blogspot.com/2015/10/gdal-and-ogr-utilities-as-library.html I need to use the "new" Translate method in the GDAL Java API. However, the Translate method is not even in GDAL2.1.0 available at Maven (TranslateOptions is in there, but not Translate). The Windoze versions of GDAL available at GISInternals also do not seem to have the Translate method, although I did find one version that has it, I've added it to an IntelliJ project as a library.
 
Question1: Is it "supposed" to be available at this time?
 
There is little/no documentation on how to use the Translate method. I'm guessing here, but the way I'm trying to use it is:
 
Vector<String> optionsVector = new Vector<>();
optionsVector.add("of PNG");
optionsVector.add("outsize 128 128");
TranslateOptions options = new TranslateOptions(optionsVector);

Dataset dst = org.gdal.gdal.gdal.Translate("b:/temp/translateTest.png", ds, options);
 
The input dataset (ds) is a GeoTiff, I'm just trying to create a .png thumbnail. The call to Translate does indeed write a translateTest.png file to disk, but it's just the original geotiff - renamed, not a .png, and not re-sized.
I do not know what the "arguments" in the optionsVector are supposed to be (It does throw an exception if I put in -of PNG, it doesn't like the hyphen), and I've also tried "one per add" (.add("of"), .add("PNG"))
 
Question2: If this thing is supposed to be ready for prime-time, what is the TranslateOptions object supposed to contain?  What is the correct way to populate it and what are valid "arguments"?
 
Help/advice appreciated.

_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: GDAL and OGR utilities as library functions?

Even Rouault-2

On mardi 3 janvier 2017 20:45:58 CET Vladimir Sandoval wrote:

> Greetings:

> Referencing this blog

> post http://erouault.blogspot.com/2015/10/gdal-and-ogr-utilities-as-library

> .html I need to use the "new" Translate method in the GDAL Java API.

> However, the Translate method is not even in GDAL2.1.0 available at Maven

> (TranslateOptions is in there, but not Translate). The Windoze versions of

> GDAL available at GISInternals also do not seem to have the Translate

> method, although I did find one version that has it, I've added it to an

> IntelliJ project as a library.

> Question1: Is it "supposed" to be available at this time?

 

To be honest, I didn't try but it looks like the method is available :

 

http://gdal.org/java/org/gdal/gdal/gdal.html#Translate(java.lang.String,%20org.gdal.gdal.Dataset,%20org.gdal.gdal.TranslateOptions)

 

and I can see it in the generated .java files from swig files.

 

>  

> There is little/no documentation on how to use the Translate method.

 

(Contributions in 2017 are as welcome as in previous years ! Hint: the file to edit is swig/java/javadoc.java and

the the doc is built with swig/java/make_doc.sh)

 

The general principles are exposed

here https://trac.osgeo.org/gdal/wiki/rfc59.1_utilities_as_a_library and should be

transposable to other languages.

 

> I'm

> guessing here, but the way I'm trying to use it is:

> Vector<String> optionsVector = new Vector<>();

> optionsVector.add("of PNG");

> optionsVector.add("outsize 128 128");

 

try

 

optionsVector.add("-of");

optionsVector.add("PNG");

optionsVector.add("-outsize");

optionsVector.add("128");

optionsVector.add("128");

 

Even

 

 

--

Spatialys - Geospatial professional services

http://www.spatialys.com


_______________________________________________
gdal-dev mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/gdal-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: GDAL and OGR utilities as library functions?

Vlad
Even, thanks for the prompt response.  Your example is indeed correct and worked just fine.  

Still having some problems with Windows GDAL version mismatches (the dreaded SwigUpcast exception), and not all versions of the Windows gdal.jar have the Translate method, but I'll get with Gisinternals to see what's going on with that.

Thanks again.
Loading...