0

I am using GeoServer and the RasterZonalStatistics tool with a land use, single-band raster dataset. In the whole raster, each pixel represents a land use category and is given values between 1 and 333, where each value represents a single category. My goal is to calculate the statistics of each land use for a selected area, which has land use values between 1 and 252.

The problem is that the results I get as a response from the server do not seem correct and to be more specific I am confused about the min and max values of each category. For example, why in each category do not have I the same min and max value (e.g. having category:10, min:10, max:10)? Or, why do not have I the min value as 1 and max value as 252 for every category but instead in some categories I have category:26, min:1, max:45?

This is a more readable format of the server response after parsing the JSON:

  • Category 1 Count 864 Max 252 Min 1 Sum 5777 Average 6.686342592592596
  • Category 3 Count 3301 Max 252 Min 1 Sum 21842 Average 6.616782793092992
  • Category 4 Count 1 Max 4 Min 4 Sum 4 Average 4
  • Category 5 Count 4857 Max 45 Min 1 Sum 26971 Average 5.5530162651842785
  • Category 6 Count 1790 Max 45 Min 3 Sum 10614 Average 5.929608938547492
  • Category 9 Count 94 Max 251 Min 9 Sum 1412 Average 15.021276595744684
  • Category 26 Count 132 Max 45 Min 1 Sum 3468 Average 26.272727272727273
  • Category 27 Count 494 Max 251 Min 1 Sum 13999 Average 28.338056680161948
  • Category 45 Count 512 Max 251 Min 1 Sum 31052 Average 60.6484375
  • Category 251 Count 148 Max 252 Min 1 Sum 18453 Average 124.68243243243242
  • Category 252 Count 43 Max 252 Min 1 Sum 1414 Average 32.883720930232556

This is the code I used:

+'<ows:Identifier>gs:RasterZonalStatistics</ows:Identifier>' 
+'<wps:DataInputs>'
+'<wps:Input>'
+'<ows:Identifier>data</ows:Identifier>'
+'<wps:Reference mimeType="image/tiff" xlink:href="http://geoserver/wcs" method="POST">'
+'<wps:Body>'
+'<wcs:GetCoverage service="WCS" version="1.1.1">'
+'<ows:Identifier>NEST:LGN2021</ows:Identifier>'
+'<wcs:DomainSubset>'
+'<ows:BoundingBox crs="http://www.opengis.net/gml/srs/epsg.xml#28992">'
+'<ows:LowerCorner>0.0 300000.0</ows:LowerCorner>'
+'<ows:UpperCorner>280000.0 625000.0</ows:UpperCorner>'
+'</ows:BoundingBox>'
+'</wcs:DomainSubset>'
+'<wcs:Output format="image/tiff"/>'
+'</wcs:GetCoverage>'
+'</wps:Body>'
+'</wps:Reference>'
+'</wps:Input>'
+'<wps:Input>'
+' <ows:Identifier>zones</ows:Identifier>'
+'<wps:Data>'
+'<wps:ComplexData mimeType="application/json"><![CDATA[' + geojsonStr +']]></wps:ComplexData>'
+'</wps:Data>'
+'</wps:Input>'
+'<wps:Input>'
+'<ows:Identifier>classification</ows:Identifier>
+'<wps:Reference mimeType="image/tiff" xlink:href="http://geoserver/wcs" method="POST">'
+'<wps:Body>'
+' <wcs:GetCoverage service="WCS" version="1.1.1">'
+'<ows:Identifier>NEST:LGN2021</ows:Identifier>'
+'<wcs:DomainSubset>'
+' <ows:BoundingBox crs="http://www.opengis.net/gml/srs/epsg.xml#28992">'
+'<ows:LowerCorner>0.0 300000.0</ows:LowerCorner>'
+'<ows:UpperCorner>280000.0 625000.0</ows:UpperCorner>'
+'</ows:BoundingBox>'
+'</wcs:DomainSubset>'
+'<wcs:Output format="image/tiff"/>'
+'</wcs:GetCoverage>'
+'</wps:Body>'
+'</wps:Reference>'
+'</wps:Input>'
+'</wps:DataInputs>'
+'<wps:ResponseForm>'
+'<wps:RawDataOutput mimeType="application/json">'
+'<ows:Identifier>statistics</ows:Identifier>'
+'</wps:RawDataOutput>'
+'</wps:ResponseForm>'
+'</wps:Execute>';```


1 Answer 1

0

The min and max values are for the pixels in that category so you would expect them to be different for each category. Consider, for example, Category 4

Category 4 Count 1 Max 4 Min 4 Sum 4 Average 4

It has a count of 1 so there is only one pixel in that category and it has a value of 4, so that is the minimum, maximum and average for that group. While category 5 has:

Category 5 Count 4857 Max 45 Min 1 Sum 26971 Average 5.5530162651842785

So there are 4857 pixels in that group with a range of values from 1 to 45 and an average of 5.55 so most of them are small values with only a few as high as 45.

2
  • Thank you for your response! But, I was wondering, if some pixels belong to the same category/land-use, then shouldn't all of them have the same pixel value? For example, all the pixels that belong in category 5 (lets say 4857 pixels) , should have the value 5 and not other values?
    – Elen
    Commented May 12, 2023 at 12:54
  • That would depend on how you constructed the categories.
    – Ian Turton
    Commented May 12, 2023 at 14:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.