pygeoprocessing.geoprocessing_core module
- pygeoprocessing.geoprocessing_core.calculate_slope()
Create a percent slope raster from DEM raster.
Base algorithm is from Zevenbergen & Thorne “Quantitative Analysis of Land Surface Topography” 1987 although it has been modified to include the diagonal pixels by classic finite difference analysis.
For the following notation, we define each pixel’s DEM value by a letter with this spatial scheme:
a b c d e f g h i
Then the slope at
e
is defined at([dz/dx]^2 + [dz/dy]^2)^0.5
Where:
[dz/dx] = ((c+2f+i)-(a+2d+g)/(8*x_cell_size) [dz/dy] = ((g+2h+i)-(a+2b+c))/(8*y_cell_size)
In cases where a cell is nodata, we attempt to use the middle cell inline with the direction of differentiation (either in x or y direction). If no inline pixel is defined, we use
e
and multiply the difference by2^0.5
to account for the diagonal projection.- Parameters
base_elevation_raster_path_band (string) – a path/band tuple to a raster of height values. (path_to_raster, band_index)
target_slope_path (string) – path to target slope raster; will be a 32 bit float GeoTIFF of same size/projection as calculate slope with units of percent slope.
raster_driver_creation_tuple (tuple) – a tuple containing a GDAL driver name string as the first element and a GDAL creation options tuple/list as the second. Defaults to geoprocessing.DEFAULT_GTIFF_CREATION_TUPLE_OPTIONS.
- Returns
None
- pygeoprocessing.geoprocessing_core.raster_band_percentile()
Calculate percentiles of a raster band.
- Parameters
base_raster_path_band (tuple) – raster path band tuple to a raster that is of any integer or real type.
working_sort_directory (str) – path to a directory that does not exist or is empty. This directory will be used to create heapfiles with sizes no larger than
heap_buffer_size
which are written in the of the pattern N.dat where N is in the numbering 0, 1, 2, … up to the number of files necessary to handle the raster.percentile_list (list) – sorted list of percentiles to report must contain values in the range [0, 100].
heap_buffer_size (int) – defines approximately how many elements to hold in a single heap file. This is proportional to the amount of maximum memory to use when storing elements before a sort and write to disk.
ffi_buffer_size (int) – defines how many elements will be stored per heap file buffer for iteration.
- Returns
A list of len(percentile_list) elements long containing the percentile values (ranging from [0, 100]) in
base_raster_path_band
where the interpolation scheme is “higher” (i.e. any percentile splits will select the next element higher than the percentile cutoff).
- pygeoprocessing.geoprocessing_core.stats_worker()
Worker to calculate continuous min, max, mean and standard deviation.
- Parameters
stats_work_queue (Queue) – a queue of 1D numpy arrays or None. If None, function puts a (min, max, mean, stddev) tuple to the queue and quits.
expected_blocks (int) – number of expected payloads through
stats_work_queue
. Will terminate after this many.
- Returns
None