<jupyter_start><jupyter_text>Regional average of raster valuesHere an average of raster values is desired over the context of some region. A RegionMask object is created, which then allows raster data to be warped onto the RegionMask's characteristics (as in the RegionMask's resolution, extent, and spatial reference system). This create a numpy matrix, from which only the pixels which lie in the region can be easily extracted and operated on.*last tested: version 1.0.2*<jupyter_code>from os.path import join

import geokit as gk
# (Here a shape file of Aachen, Germany will be used)
regionPath = join(gk._test_data_, "aachenShapefile.shp")

# Create a region mask from a region definition
rm = gk.RegionMask.fromVector(regionPath)
# Warp a raster file onto the RegionMask's context (Here, a simple elevation raster file is used)
rasterFile = join(gk._test_data_, "elevation.tif")

warpedMatrix = rm.warp(rasterFile)
# Compute the average of pixels the region mask
meanValue = warpedMatrix[ rm.mask ].mean()

print("Mean raster value:", meanValue)<jupyter_output>Mean raster value: 307.869
{'fraction_non_alphanumeric': 0.06953339432753888, 'fraction_numerical': 0.008234217749313814, 'mean_word_length': 5.4733727810650885, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '487978', 'license': 'MIT', 'n_tokens_mistral': 330, 'n_tokens_neox': 315, 'n_words': 140, 'path': 'Examples/regional_raster_average.ipynb', 'repo_name': 'ENSYSTRA/geokit', 'size': '1093'}