Async Raster Analysis
This module provides functionality for working with async raster analysis methods.
- class AsyncRasterAnalysis(api, data={})[source]
Bases:
AsyncBase- Parameters:
api (AsyncGeoboxClient)
data (Dict | None)
- BASE_ENDPOINT = 'analysis/'
- __init__(api, data={})[source]
[async] Initialize a workflow instance.
- Parameters:
api (AsyncGeoboxClient) – The AsyncGeoboxClient instance for making requests.
uuid (str) – The unique identifier for the workflow.
data (Dict) – The response data of the workflow.
- async rasterize(layer, output_raster_name, pixel_size=10, nodata=-9999, data_type=AnalysisDataType.int16, burn_value=1, burn_attribute=None, user_id=None)[source]
[async] Rasterize a vector layer
This method converts a vector layer (or view) to a raster dataset using the specified parameters. You can control the output raster’s name, pixel size, data type, nodata value, and the value to burn (either a constant or from an attribute field). Only users with Publisher role or higher can perform this operation.
- Parameters:
layer (AsyncVectorLayer | AsyncVectorLayerView) – VectorLayer or VectorLayerView instance
output_raster_name (str) – Name for the output raster dataset
pixel_size (int, optional) – Pixel size for the output raster (must be > 0). default: 10
nodata (int, optional) – NoData value to use in the output raster. default: -9999
data_type (AnalysisDataType, optional) – Data type for the output raster (e.g., int16, float32). default: AnalysisDataType.int16
burn_value (int, optional) – Value to burn into the raster for all features (if burn_attribute is not set). default: 1
burn_attribute (str, optional) – Name of the attribute field to use for burning values into the raster
user_id (int, optional) – specific user. priviledges required!
- Returns:
task instance of the process
- Return type:
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis >>> async with AsyncGeoboxClient() as client: >>> vector = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678") >>> task = await client.raster_analysis.rasterize(layer=vector, output_raster_name='test') or >>> raster_analysis = AsyncRasterAnalysis(client) >>> task = await raster_analysis.rasterize(layer=vector, output_raster_name='test')
- async polygonize(raster, output_layer_name, band_index=1, value_field=None, mask_nodata=False, connectivity=PolygonizeConnectivity.connected_4, keep_values=None, layer_name=None, user_id=None)[source]
[async] Convert a raster to vector polygons
vectorizes a raster (polygonize) to a vector dataset (*.gpkg). Only users with Publisher role or higher can perform this operation
- Parameters:
raster (Raster) – Raster instance
output_layer_name (str) – Name for the output vector layer.
band_index (int, optional) – Raster band to polygonize. default: 1
value_field (str, optional) – Name of attribute field storing the pixel value. default: None
mask_nodata (bool, optional) – If True, NoData pixels are excluded using the band mask. default: False
connectivity (PolygonizeConnectivity, optional) – 4 or 8 connectivity for region grouping. default: PolygonizeConnectivity.connected_4
keep_values (str, optional) – JSON array of values to keep (e.g., ‘[1,2,3]’). default: None
layer_name (str, optional) – Output layer name. default: None
user_id (int, optional) – specific user. priviledges required!
- Returns:
task instance of the process
- Return type:
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis >>> async with AsyncGeoboxClient() as client: >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678") >>> task = await client.raster_analysis.polygonize(raster=raster, output_layer_name='test') or >>> raster_analysis = AsyncRasterAnalysis(client) >>> task = await raster_analysis.polygonize(raster=raster, output_layer_name='test')
- async clip(raster, layer, output_raster_name, where=None, dst_nodata=-9999, crop=True, resample=AnalysisResampleMethod.near, user_id=None)[source]
[async] Clip a raster using a vector layer as a mask
clips a raster dataset using a vector layer as the clipping boundary. Only users with Publisher role or higher can perform this operation
- Parameters:
raster (Raster) – Raster instance
layer (AsyncVectorLayer | AsyncVectorLayerView) – VectorLayer or VectorLayerView instance
output_raster_name (str) – Name for the output raster dataset
where (str, optional) – Optional attribute filter, e.g. ‘VEG=forest’.
dst_nodata (int, optional) – Output NoData value. default: -9999
crop (bool, optional) – True=shrink extent to polygon(s); False=keep full extent but mask outside. default: True
resample (CropResample, optional) – Resampling method: ‘near’, ‘bilinear’, ‘cubic’, ‘lanczos’, etc. default: CropResample.near
user_id (int, optional) – specific user. priviledges required!
- Returns:
task instance of the process
- Return type:
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis >>> async with AsyncGeoboxClient() as client: >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678") >>> vector = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678") >>> task = await client.raster_analysis.clip(raster=raster, layer=vector, output_raster_name='test') or >>> raster_analysis = AsyncRasterAnalysis(client) >>> task = await raster_analysis.clip(raster=raster, layer=vector, output_raster_name='test')
- async calculator(variables, expr, output_raster_name, match_raster_uuid=None, resample=AnalysisResampleMethod.bilinear, out_dtype=AnalysisDataType.float32, dst_nodata=-9999, user_id=None)[source]
[async] Perform raster calculator operations on multiple raster datasets.
it allows you to perform mathematical operations on one or more raster datasets using NumPy expressions. Variables in the expression correspond to raster datasets specified in the variables dictionary.
Example
NDVI calculation: variables=’{“NIR”: “raster_uuid_1”, “RED”: “raster_uuid_2”}’, expr=”(NIR-RED)/(NIR+RED)” Slope threshold: variables=’{“SLOPE”: “raster_uuid_1”}’, expr=”np.where(SLOPE>30,1,0)” Multi-band operations: variables=’{“IMG”: [“raster_uuid_1”, 2]}’, expr=”IMG*2”
- Parameters:
variables (str) – JSON string mapping variable names to raster specifications. Format: ‘{“NIR”: “raster_uuid_1”, “RED”: “raster_uuid_2”}’ or ‘{“IMG”: [“raster_uuid_1”, 2]}’ for multi-band operations.
expr (str) – Mathematical expression using NumPy syntax. Use variable names from the variables dict, e.g., ‘(NIR-RED)/(NIR+RED)’ or ‘where(SLOPE>30,1,0)’ or ‘where((dist_to_highway < 1000) & (slope < 10), 1, 0)’ .Supported functions: np, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, exp, log, log10, sqrt, abs, floor, ceil, round, minimum, maximum, clip, where, isnan, isfinite, pi, e.
output_raster_name (str) – Name for the output raster dataset.
match_raster_uuid (str, optional) – Optional raster UUID to match the output grid and projection. If not provided, the first variable becomes the reference grid.
resample (CropResample, optional) – Resampling method: ‘near’, ‘bilinear’, ‘cubic’, ‘lanczos’, etc. default: CropResample.near
out_dtype (AnalysisDataType, optional) – Data type for the output raster (e.g., int16, float32). default: AnalysisDataType.float32
dst_nodata (int, optional) – NoData value for the output raster. default = -9999
user_id (int, optional) – specific user. priviledges required!
- Returns:
task instance of the process
- Return type:
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis >>> async with AsyncGeoboxClient() as client: >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678") >>> task = await client.raster_analysis.calculator(variables={"NIR": "raster_uuid_1", "RED": "raster_uuid_2"}, ... expr='where(SLOPE>30,1,0)', ... output_raster_name='test') or >>> raster_analysis = AsyncRasterAnalysis(client) >>> task = raster_analysis.calculator(variables={"NIR": "raster_uuid_1", "RED": "raster_uuid_2"}, ... expr='where(SLOPE>30,1,0)', ... output_raster_name='test')
- async slope(raster, output_raster_name, slope_units=SlopeUnit.degree, algorithm=AnalysisAlgorithm.Horn, scale=1, compute_edges=True, nodata_out=-9999, user_id=None)[source]
[async] Calculate slope from a DEM raster.
This endpoint creates a slope raster from a Digital Elevation Model (DEM). Only users with Publisher role or higher can perform this operation.
- Parameters:
raster (Raster) – DEM Raster instance
output_raster_name (str) – Name for the output raster dataset.
slope_units (SlopeUnit, optional) – Slope units: ‘degree’ or ‘percent’. default: SlopeUnit.degree
algorithm (AnalysisAlgorithm, optional) – Algorithm: ‘Horn’ or ‘ZevenbergenThorne’. default: AnalysisAlgorithm.Horn
scale (int, optional) – Ratio of vertical units to horizontal units. default: 1
compute_edges (bool, optional) – Whether to compute edges. default: True
nodata (int, optional) – NoData value for the output raster. default = -9999
user_id (int, optional) – specific user. priviledges required!
nodata_out (int)
- Returns:
task instance of the process
- Return type:
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis >>> async with AsyncGeoboxClient() as client: >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678") >>> task = await client.raster_analysis.slope(raster=raster, output_raster_name='test') or >>> raster_analysis = AsyncRasterAnalysis(client) >>> task = await raster_analysis.slope(raster=raster, output_raster_name='test')
- async aspect(raster, output_raster_name, algorithm=AnalysisAlgorithm.Horn, trigonometric=False, zero_for_flat=True, compute_edges=True, nodata_out=-9999, user_id=None)[source]
[async] Calculate aspect from a DEM raster.
it creates an aspect raster (degrees 0–360) from a Digital Elevation Model (DEM). Only users with Publisher role or higher can perform this operation.
- Parameters:
raster (Raster) – DEM Raster instance
output_raster_name (str) – Name for the output raster dataset.
algorithm (AnalysisAlgorithm, optional) – Algorithm: ‘Horn’ or ‘ZevenbergenThorne’. default: AnalysisAlgorithm.Horn
trigonometric (bool, optional) – False: azimuth (0°=N, 90°=E, clockwise); True: 0°=E, counter-clockwise. default: False
zero_for_flat (bool, optional) – Set flats (slope==0) to 0 instead of NoData. default: True
compute_edges (bool, optional) – Whether to compute edges. default: True
nodata (int, optional) – NoData value for the output raster. default = -9999
user_id (int, optional) – specific user. priviledges required!
nodata_out (int)
- Returns:
task instance of the process
- Return type:
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis >>> async with AsyncGeoboxClient() as client: >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678") >>> task = await client.raster_analysis.aspect(raster=raster, output_raster_name='test') or >>> raster_analysis = AsyncRasterAnalysis(client) >>> task = await raster_analysis.aspect(raster=raster, output_raster_name='test')
- async reclassify(raster, output_raster_name, rules, default_value=None, nodata_in=-9999, nodata_out=-9999, out_dtype=AnalysisDataType.int16, inclusive=RangeBound.left, user_id=None)[source]
[async] Reclassify a raster using value mapping or class breaks.
This endpoint reclassifies raster values according to specified rules. Only users with Publisher role or higher can perform this operation.
- Parameters:
raster (Raster) – Raster instance
output_raster_name (str) – Name for the output reclassified raster dataset.
rules (str) – JSON string containing reclassification rules. For mode=’exact’, it should be a dict {old_value: new_value}. For mode=’range’, it should be a list of (low, high, new_value). Example for mode=’exact’: ‘{“1”: 10, “2”: 20, “3”: 30}’. Example for mode=’range’: ‘[[0, 10, 1], [10, 20, 2], [20, 30, 3]]’. the method would detect the mode type based on the rules input.
default_value (str, optional) – Value to assign when a pixel matches no rule.
nodata_in (int, optional) – NoData of input. If None, tries to get from the input raster.
nodata_out (int, optional) – NoData value to set on output band.
out_dtype (AnalysisDataType, optional) – Output data type. default: AnalysisDataType.int16
inclusive (RangeBound, optional) – Range bound semantics for mode=’range’: ‘left’, ‘right’, ‘both’, ‘neither’. default: RangeBound.left
user_id (int, optional) – specific user. priviledges required!
- Returns:
task instance of the process
- Return type:
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis >>> async with AsyncGeoboxClient() as client: >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678") >>> task = await client.raster_analysis.reclassify(raster=raster, output_raster_name='test', rules='{"1": 10, "2": 20, "3": 30}') or >>> raster_analysis = AsyncRasterAnalysis(client) >>> task = raster_analysis.reclassify(raster=raster, output_raster_name='test', rules='{"1": 10, "2": 20, "3": 30}')
- async resample(raster, output_raster_name, out_res=None, scale_factor=None, match_raster_uuid=None, resample_method=AnalysisResampleMethod.near, dst_nodata=-9999, user_id=None)[source]
[async] Resample a raster to a different resolution.
it resamples a raster using GDAL Warp. Exactly one of out_res, scale_factor, or match_raster_uuid must be provided. Only users with Publisher role or higher can perform this operation.
- Parameters:
raster (Raster) – Raster instance
output_raster_name (str) – Name for the output reclassified raster dataset.
out_res (str, optional) – Output resolution as ‘x_res,y_res’ (e.g., ‘10,10’).
scale_factor (int, optional) – Scale factor (e.g., 2.0 for 2x finer resolution).
match_raster_uuid (str, optional) – UUID of reference raster to match resolution/extent.
resample_method (AnalysisResampleMethod, optional) – Resampling method: ‘near’, ‘bilinear’, ‘cubic’, ‘lanczos’, etc.
dst_nodata (int, optional) – Output NoData value.
user_id (int, optional) – specific user. priviledges required!
- Returns:
task instance of the process
- Return type:
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis >>> async with AsyncGeoboxClient() as client: >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678") >>> task = await client.raster_analysis.resample(raster=raster, output_raster_name='test', out_res='10,10') or >>> raster_analysis = AsyncRasterAnalysis(client) >>> task = await raster_analysis.resample(raster=raster, output_raster_name='test', out_res='10,10')
- async idw_interpolation(layer, output_raster_name, z_field, match_raster_uuid=None, pixel_size=10, extent=None, power=2.0, smoothing=0.0, max_points=16, radius=1000, nodata=-9999, out_dtype=AnalysisDataType.float32, user_id=None)[source]
[async] Create an IDW (Inverse Distance Weighting) interpolation raster from point data.
it creates a raster using IDW interpolation from point data in a vector layer. Only users with Publisher role or higher can perform this operation.
- Parameters:
layer (AsyncVectorLayer | AsyncVectorLayerview) – layer containing point data
output_raster_name (str) – Name for the output IDW raster dataset.
z_field (Field) – the field containing the values to interpolate.
match_raster_uuid (str, optional) – UUID of reference raster to match resolution/extent.
pixel_size (int, optional) – Pixel size for the output raster. default: 10
extent (str, optional) – Extent as ‘minX,minY,maxX,maxY’.
power (float, optional) – Power parameter for IDW. default: 2.0
smoothing (float, optional) – Smoothing parameter for IDW. default: 0.0
max_points (int, optional) – Maximum number of neighbors to use. default: 16
radius (int, optional) – Search radius in map units. default: 1000
nodata (int, optional) – NoData value for the output raster. default: -9999
out_dtype (AnalysisDataType, optional) – Output data type.
user_id (int, optional) – specific user. priviledges required!
- Returns:
task instance of the process
- Return type:
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis >>> async with AsyncGeoboxClient() as client: >>> vector = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678") >>> field = await vector.get_field_by_name('field_name') >>> task = await client.raster_analysis.idw_interpolation(layer=vector, output_raster_name='test', z_field=field) or >>> raster_analysis = AsyncRasterAnalysis(client) >>> task = await raster_analysis.idw_interpolation(layer=vector, output_raster_name='test', z_field=field)
- async constant(output_raster_name, extent, value, pixel_size=10, dtype=AnalysisDataType.float32, nodata=-9999, align_to=None, user_id=None)[source]
[async] Create a raster filled with a constant value.
This endpoint creates a north-up GeoTIFF filled with a constant value. Only users with Publisher role or higher can perform this operation.
- Parameters:
output_raster_name (str) – Name for the output constant raster dataset.
extent (str) – Extent as ‘minX,minY,maxX,maxY’ (e.g., ‘0,0,100,100’).
value (int) – Constant value to fill the raster with.
pixel_size (int, optional) – Pixel size for the output raster (must be > 0). default: 10
dtype (AnalysisDataType, optoinal) – Output data type. default: AnalysisDataType.float32
nodata (int, optional) – NoData value for the raster. default: -9999
align_to (str, optional) – Grid origin to snap to as ‘x0,y0’ (e.g., ‘0,0’).
user_id (int, optional) – specific user. priviledges required!
- Returns:
task instance of the process
- Return type:
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis >>> async with AsyncGeoboxClient() as client: >>> task = await client.raster_analysis.constant(output_raster_name='test', extent='0,0,100,100', value=10) or >>> raster_analysis = AsyncRasterAnalysis(client) >>> task = await raster_analysis.constant(output_raster_name='test', extent='0,0,100,100', value=10)
- async fill_nodata(raster, output_raster_name, band=1, nodata=None, max_search_dist=None, smoothing_iterations=None, mask_raster_uuid=None, user_id=None)[source]
[async] Fill NoData regions in a raster using GDAL’s FillNodata algorithm.
it fills gaps (NoData regions) in a raster by interpolating values from surrounding valid pixels. This is commonly used for data cleaning and gap filling in remote sensing and elevation data. Only users with Publisher role or higher can perform this operation.
- Parameters:
raster (Raster) – the input raster to fill NoData regions in
output_raster_name (str) – Name for the output filled raster dataset.
band (int | str) – 1-based band index to process or ‘all’ to process all bands. default: 1
nodata (int, optional) – NoData value to use. If None, uses the band’s existing NoData.
max_search_dist (int, optoinal) – Maximum distance in pixels to search for valid data.
smoothing_iterations (int, optional) – Number of smoothing iterations to apply.
mask_raster_uuid (str, optional) – Optional UUID of a mask raster (0=masked, >0=valid).
user_id (int, optional) – specific user. priviledges required!
- Returns:
task instance of the process
- Return type:
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis >>> async with AsyncGeoboxClient() as client: >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678") >>> task = await client.raster_analysis.fill_nodata(raster=raster, output_raster_name='test') or >>> raster_analysis = AsyncRasterAnalysis(client) >>> task = await raster_analyis.fill_nodata(raster=raster, output_raster_name='test')
- async proximity(raster, output_raster_name, dist_units=DistanceUnit.GEO, burn_value=1, nodata=-9999, user_id=None)[source]
[async] Create a proximity (distance) raster from a raster layer.
it creates a raster showing the distance from each pixel to the nearest pixel in the input raster layer. Only users with Publisher role or higher can perform this operation.
- Parameters:
raster (Raster) – the raster layer to create proximity raster from.
output_raster_name (str) – Name for the output proximity raster dataset.
dist_units (DistanceUnit, optional) – Distance units: ‘GEO’ for georeferenced units, ‘PIXEL’ for pixels. default: DistanceUnit.GEO
burn_value (int, optional) – Value treated as targets (distance 0). default: 1
nodata (int, optional) – NoData value to use in the output raster. default: -9999
user_id (int, optional) – specific user. priviledges required!
- Returns:
task instance of the process
- Return type:
Example
>>> from geobox.aio import AsyncGeoboxClient >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis >>> async with AsyncGeoboxClient() as client: >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678") >>> task = await client.raster_analysis.proximity(raster=raster, output_raster_name='test') or >>> raster_analysis = AsyncRasterAnalysis(client) >>> task = await raster_analysis.proximity(raster=raster, output_raster_name='test')