Skip to content

Commit

Permalink
processing zonal statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
ghtmtt authored and m-kuhn committed Jan 13, 2017
1 parent c259070 commit 8994877
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 0 deletions.
@@ -0,0 +1,66 @@
<GMLFeatureClassList>
<GMLFeatureClass>
<Name>zonal_statistics</Name>
<ElementPath>zonal_statistics</ElementPath>
<!--POLYGON-->
<GeometryType>3</GeometryType>
<SRSName>EPSG:4326</SRSName>
<DatasetSpecificInfo>
<FeatureCount>2</FeatureCount>
<ExtentXMin>18.67319</ExtentXMin>
<ExtentXMax>18.70090</ExtentXMax>
<ExtentYMin>45.77796</ExtentYMin>
<ExtentYMax>45.80786</ExtentYMax>
</DatasetSpecificInfo>
<PropertyDefn>
<Name>_min</Name>
<ElementPath>_min</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>_max</Name>
<ElementPath>_max</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>_sum</Name>
<ElementPath>_sum</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>_count</Name>
<ElementPath>_count</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>_mean</Name>
<ElementPath>_mean</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>_std</Name>
<ElementPath>_std</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>_unique</Name>
<ElementPath>_unique</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>_range</Name>
<ElementPath>_range</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>_var</Name>
<ElementPath>_var</ElementPath>
<Type>Real</Type>
</PropertyDefn>
<PropertyDefn>
<Name>_median</Name>
<ElementPath>_median</ElementPath>
<Type>Real</Type>
</PropertyDefn>
</GMLFeatureClass>
</GMLFeatureClassList>
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8" ?>
<ogr:FeatureCollection
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=""
xmlns:ogr="http://ogr.maptools.org/"
xmlns:gml="http://www.opengis.net/gml">
<gml:boundedBy>
<gml:Box>
<gml:coord><gml:X>18.67319311115957</gml:X><gml:Y>45.77795780842602</gml:Y></gml:coord>
<gml:coord><gml:X>18.70090093189771</gml:X><gml:Y>45.80786158698488</gml:Y></gml:coord>
</gml:Box>
</gml:boundedBy>

<gml:featureMember>
<ogr:zonal_statistics fid="polygon_mask.0">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>18.6744202640594,45.7984964727494 18.6832040953424,45.8078615869849 18.6896627948151,45.8045676502538 18.6948297543933,45.8001757346123 18.694442232425,45.7962359279339 18.6838499652896,45.7903585114137 18.6759703519329,45.7902293374243 18.6731931111596,45.7899709894453 18.6744202640594,45.7984964727494</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:_min>85.000000</ogr:_min>
<ogr:_max>230.000000</ogr:_max>
<ogr:_sum>3498496.250000</ogr:_sum>
<ogr:_count>24890.000000</ogr:_count>
<ogr:_mean>140.558307</ogr:_mean>
<ogr:_std>39.336077</ogr:_std>
<ogr:_unique>23959.000000</ogr:_unique>
<ogr:_range>145.000000</ogr:_range>
<ogr:_var>1547.326959</ogr:_var>
<ogr:_median>141.308746</ogr:_median>
</ogr:zonal_statistics>
</gml:featureMember>
<gml:featureMember>
<ogr:zonal_statistics fid="polygon_mask.1">
<ogr:geometryProperty><gml:Polygon srsName="EPSG:4326"><gml:outerBoundaryIs><gml:LinearRing><gml:coordinates>18.6906961867308,45.7866124657195 18.694442232425,45.7911335553504 18.7009009318977,45.7856436607986 18.6997383659926,45.7811225711677 18.6884356419153,45.777957808426 18.6804914415638,45.7798954182678 18.6800393326007,45.7833185289884 18.6906961867308,45.7866124657195</gml:coordinates></gml:LinearRing></gml:outerBoundaryIs></gml:Polygon></ogr:geometryProperty>
<ogr:_min>121.586990</ogr:_min>
<ogr:_max>209.600006</ogr:_max>
<ogr:_sum>2569446.750000</ogr:_sum>
<ogr:_count>14940.000000</ogr:_count>
<ogr:_mean>171.984388</ogr:_mean>
<ogr:_std>21.902397</ogr:_std>
<ogr:_unique>14404.000000</ogr:_unique>
<ogr:_range>88.013016</ogr:_range>
<ogr:_var>479.714993</ogr:_var>
<ogr:_median>179.076462</ogr:_median>
</ogr:zonal_statistics>
</gml:featureMember>
</ogr:FeatureCollection>
17 changes: 17 additions & 0 deletions python/plugins/processing/tests/testdata/qgis_algorithm_tests.yaml
Expand Up @@ -2214,3 +2214,20 @@ tests:
OUTPUT:
name: expected/single_to_multi.gml
type: vector

- algorithm: qgis:zonalstatistics
name: simple zonal statistics
params:
COLUMN_PREFIX: _
GLOBAL_EXTENT: false
INPUT_RASTER:
name: dem.tif
type: raster
INPUT_VECTOR:
name: custom/polygon_mask.gml
type: vector
RASTER_BAND: 1
results:
OUTPUT_LAYER:
name: expected/zonal_statistics.gml
type: vector

0 comments on commit 8994877

Please sign in to comment.