Dear list,
I’m trying to execute the slope base process from Sextante (using the community
module wps-sextante built from source for the stable version) of a dem layer.
The result doesn't have any error in the logs but comes with all nodata values
at -9999.
This happens also with different algorithm like aspect for instance. The only
way that seems to solve this behavior is by saving the coverage to a file and
then read it back before passing the coverage to the sestante algorithm. In
fact if I write my own slope wps simply adding this further snippet:
// coverage is the input GridCoverage2D
//write coverage to file
Path writedir = Paths.get(new
StringBuilder("/tmp").append(File.separatorChar).append(Slope.class.getSimpleName()).toString());
if (!Files.exists(writedir)) {
try {
Files.createDirectories(writedir);
} catch (IOException e) {
//fail to create directory
e.printStackTrace();
}
}
String filename = new
StringBuilder(writedir.toAbsolutePath().toString()).append(File.separatorChar).append(cropped.getName().toString()).append(".tiff").toString();
final File writeFile = new File(filename);
writeToGeotiff(coverage, filename);
//read coverage from file
GridCoverage2D lCov = getLocalCoverage(writeFile.getName());
######
//writeToGeotiff
static void writeToGeotiff(GridCoverage2D cov, String fileName) {
try {
GeoTiffWriteParams wp = new GeoTiffWriteParams();
wp.setCompressionMode(GeoTiffWriteParams.MODE_EXPLICIT);
wp.setCompressionType("LZW");
ParameterValueGroup params = new
GeoTiffFormat().getWriteParameters();
params.parameter(AbstractGridFormat.GEOTOOLS_WRITE_PARAMS.getName().toString()).setValue(wp);
File wfile = new File(fileName);
LOG.info("wfile="+wfile);
new GeoTiffWriter(wfile).write(cov, (GeneralParameterValue[])
params.values().toArray(new GeneralParameterValue[1]));
} catch (Exception e) {
LOG.severe("exception while writing geotiff.");
e.printStackTrace();
}
}
//getLocalCoverage
static GridCoverage2D getLocalCoverage(String filename) throws Exception {
File file = new
File("/tmp"+File.separatorChar+Slope.class.getSimpleName()+File.separatorChar+filename);
LOG.info("geotiff file to read "+file.toString());
AbstractGridFormat format = GridFormatFinder.findFormat(file);
GridCoverage2DReader reader = format.getReader(file);
GridCoverage2D coverage = reader.read(null);
LOG.info("coverage=" + coverage);
return coverage;
}
######
then the process outputs a geotiff with expected slope values.
Obviously this is much more time consuming than expected and not good in term
of performance. Does anybody know if there have been successful cases in the
past with sextante algorithms and maybe has ideas why this is happening?
I’m open to improve and add this kind of test to the module if needed and then
contribute back.
Thanks in advance for your help
Francesco
------------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users