Hello,

We have recently had some trouble using the RasterZonalStatistics2 raster process from Geoserver and would like to share our experience. It might be useful for someone having our same problem, or maybe be used to improve the process's code itself.

The RasterZonalStatistics2 [1] process is distributed under the unsupported process-raster module in geotools. As far as I know it can't be used directly from Geoserver WPS (it's not available in the list), but can be used to build a custom WPS process. That's how we have been using it. Among other parameters, the process takes two main inputs: a raster layer, and a list of features for which to compute the statistics for.

The problem we were having is that we realized that the calculated stats by the process were being affected by the extent of the raster layer. Same features, different raster extent was giving different results.

After digging on the geotools code we found that the features we provided to the process were being silently discarded when building the ROI. The reason is that the code checks if the coverage and the features intersect [2], but doesn't make sure that when comparing the values the same CRS is being used. In our case the raster CRS was on degrees, and the feature on meters, so the feature was being discarded because it didn't intersect.

As we were using the smallest possible extent for the raster to match the zones it took us a while to realize that the stats were being calculated for the whole raster, and not the expected zones.

Maybe it's expected to provide all inputs in the same CRS for this kind of process, maybe it's a general rule that I wasn't aware of. But if not maybe one of the following improvements could be implemented:

 * Document in the 'RasterZonalStatistics2' process that the 'coverage'
   and 'zones' CRS must be the same.
 * Add some warning log if the provided 'zones' are being discarded
   because they don't interesect [2]
 * Make some reprojection if both parameters don't share the CRS. Not
   sure if that should be handled in the 'RasterZonalStatistics2'
   process, or in the underneath 'ZonalStatistics' operation.

Thank you

[1] https://github.com/geotools/geotools/blob/main/modules/unsupported/process-raster/src/main/java/org/geotools/process/raster/RasterZonalStatistics2.java

[2] https://github.com/geotools/geotools/blob/main/modules/library/coverage/src/main/java/org/geotools/coverage/processing/operation/ZonalStatistics.java#L188-L190

--
*BINGEN GALARTZA IPARRAGIRRE*




magnet.coop
Santa Marina 3, OƱati (20560)
i...@magnet.coop
*www.magnet.coop*

/This e-mail and the documents attached are confidential and intended solely for the addressee; it may also be privileged. If you receive this communication in error, please notify the sender immediately and delete it. If you are not the intended recipient, you are expressly prohibited from reading, copying, distributing, disseminating or, in any other way, using any of the information without the Magnet consent. Please note that Internet e-mail guarantees neither the confidentiality nor the proper receipt of the message sent, so that Magnet shall not be liable for any damages caused. As its integrity cannot be secured on the Internet, the Magnet liability cannot be triggered for the message content. Although the sender endeavors to maintain a computer virus-free network, the sender does not warrant that this transmission is virus-free and will not be liable for any damages resulting from any virus transmitted./
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to