satproc package
Subpackages
- satproc.console namespace
- Submodules
- satproc.console.extract_chips module
- satproc.console.filter module
- satproc.console.generalize module
- satproc.console.make_masks module
- satproc.console.match_histograms module
- satproc.console.polygonize module
- satproc.console.scale module
- satproc.console.smooth_stitch module
- satproc.console.spatial_filter module
- satproc.postprocess namespace
Submodules
satproc.chips module
- satproc.chips.extract_chips(rasters, aoi=None, labels=None, label_property='class', masks={'extent'}, mask_type='class', extent_no_border=False, rescale_mode=None, rescale_range=None, bands=None, chip_type='tif', write_footprints=False, classes=None, crs=None, skip_existing=True, within=False, windows_mode='whole_overlap', skip_low_contrast=False, skip_with_empty_mask=True, *, size, step_size, output_dir)[source]
- satproc.chips.extract_chips_from_raster(raster, rescale_mode=None, rescale_range=None, bands=None, chip_type='tif', write_footprints=False, labels=None, label_property='class', mask_type='class', masks={'extent'}, classes=None, crs=None, skip_existing=True, within=False, aoi_poly=None, polys_dict=None, windows_mode='whole_overlap', skip_low_contrast=False, skip_with_empty_mask=True, extent_no_border=False, *, size, step_size, output_dir)[source]
satproc.filter module
satproc.histogram module
- satproc.histogram.match_histograms(src_path, dst_path, size=128, step_size=128, *, reference_path)[source]
Match histograms of an image using another one as reference
- satproc.histogram.read_window(ds, window)[source]
Read from a rasterio dataset using a window
NaNs are coerced to zero.
- Parameters
ds (rasterio.Dataset) – input dataset
window (rasterio.windows.Window) – window to read from
- Returns
image data on window
- Return type
- satproc.histogram.write_window(img, ds, window)[source]
Write array to raster on window
- Parameters
img (numpy.ndarray) – image array
ds (rasterio.Dataset) – dataset to write to (must be opened with write access)
window (rasterio.windows.Window) – window to write to
- Return type
None
satproc.masks module
- satproc.masks.make_masks(rasters, *, output_dir, labels, label_property='class', classes=None, mask_type='class', masks={'extent'}, extent_no_border=False)[source]
- satproc.masks.mask_from_polygons(polygons, *, win, t, extent_no_border=True, boundary_mask=None, distance_mask=None)[source]
Generate a binary mask array from a set of polygon
It can also generate a distance transform mask
- Parameters
polygons (List[Union[Polygon, MultiPolygon]]) – list of polygon or multipolygon geometries
win (rasterio.windows.Window) – window
t (rasterio.transform.Affine) – affine transform
extent_no_border (bool) – if True, the extent mask will not include the border of the polygon
boundary_mask (bool) – whether to generate boundary (edges) mask
distance_mask (bool) – whether to generate a distance mask
- Return type
- satproc.masks.multiband_chip_mask_by_classes(classes, transform, window, label_property, polys_dict=None, label_path=None, extent_mask_path=None, boundary_mask_path=None, distance_mask_path=None, extent_no_border=False)[source]
satproc.scale module
- satproc.scale.get_min_max(img, window_size=512)[source]
Return minimum and maximum values on array, in blocks
- Parameters
img (numpy.ndarray) – image array
window_size (int) – size of window (default: 512)
- Returns
minimum and maximum values
- Return type
- satproc.scale.minmax_scale(img, *, min_values, max_values)[source]
Scale bands of image separately, to range 0..1
- Parameters
img (numpy.ndarray) – image array
min_values (List[float]) – minimum values for each band
max_values (List[float]) – maximum values for each band
- Returns
rescaled image
- Return type
satproc.utils module
- satproc.utils.grouper(iterable, n, fillvalue=None)[source]
Collect data into fixed-length chunks or blocks
- satproc.utils.map_with_threads(items, worker, num_jobs=None, total=None, desc=None)[source]
Map a worker function to an iterable of items, using a thread pool
- Parameters
- Return type
None
- satproc.utils.reproject_shape(shp, from_crs, to_crs, project=None)[source]
Reproject a shape from from_crs to to_crs
- satproc.utils.rescale_intensity(image, rescale_mode, rescale_range)[source]
Calculate percentiles from a range cut and rescale intensity of image to byte range
- Parameters
image (numpy.ndarray) – image array
rescale_mode (str) – rescaling mode, either ‘percentiles’ or ‘values’
rescale_range (Tuple[number, number]) – input range for rescaling
- Returns
rescaled image
- Return type
- satproc.utils.sliding_windows(size, step_size, width, height, mode='exact')[source]
Slide a window of +size+ by moving it +step_size+ pixels
- Parameters
size (int) – window size, in pixels
step_size (int) – step or stride size when sliding window, in pixels
width (int) – image width
height (int) – image height
mode (str (default: 'exact')) – either one of ‘exact’, ‘whole’, ‘whole_overlap’. - ‘exact’: clip windows at borders, if needed - ‘whole’: only whole windows - ‘whole_overlap’: only wohle windows, allow overlapping windows at borders.
- Yields
Tuple[Window, Tuple[int, int]] – a pair of Window and a pair of position (i, j)
- satproc.utils.write_chips_geojson(output_path, chip_pairs, *, chip_type, crs, basename)[source]
Write a GeoJSON containing chips polygons as features
- Parameters
output_path (str) – GeoJSON output path
chip_pairs (Tuple[Shape, Tuple[int, int, int]]) – a pair with the chip polygon geometry, and a tuple of (feature id, x, y)
chip_type (str) – chip file type extension (e.g. tif, jpg)
crs (str) – CRS epsg code of chip polygon geometry
basename (str) – basename of chip files
- Return type
None