raptorstats.scanline module
- class raptorstats.scanline.Scanline[source]
Bases:
ZonalStatMethod
- raptorstats.scanline.build_intersection_table(features: geopandas.GeoDataFrame, raster: rasterio.DatasetReader)[source]
Intersect features with scanlines and return the intersection table.
- Parameters:
features (gpd.GeoDataFrame)
raster (rio.DatasetReader)
- Returns:
f_index, (y, x0, x1) coordinates
- Return type:
(np.ndarray(int), np.ndarray(float))
- Raises:
TypeError – If the intersection type is not LineString or MultiLineString
- raptorstats.scanline.build_reading_table(f_index, intersection_coords, raster: rasterio.DatasetReader, return_coordinates=False, sort_by_feature=False)[source]
Create a reading table indicating which pixels to read for each feature.
- Parameters:
intersection_table (np.ndarray) – A 2D array containing feature index, y coordinate, x0 coordinate, and x1 coordinate
raster (rio.DatasetReader) – A rasterio dataset reader object
return_coordinates (bool, optional) – Whether to return the coordinates of the pixels, by default False
sort_by_feature (bool, optional) – Whether to sort the reading table by feature index and then by row, instead of just by row, by default False
- Returns:
(row, col0, col1, f_index), (y, x0, x1) if return_coordinates is True
- Return type:
np.ndarray or tuple of np.ndarray
- raptorstats.scanline.process_reading_table(reading_table: ndarray, features: geopandas.GeoDataFrame, raster: rasterio.DatasetReader, stats: Stats, partials=None, max_collected_rows_percentage=10)[source]
Read the pixels indicated by the reading table and compute statistics.
- Parameters:
reading_table (np.ndarray) – A 2D array containing the reading table information
features (gpd.GeoDataFrame) – A GeoDataFrame containing the features
raster (rio.DatasetReader) – A rasterio dataset reader object
stats (Stats) – A Stats object for computing statistics
partials (list, optional) – A list of partial per-feature statistics to combine with the computed statistics, by default None
- Returns:
A list of statistics for each feature
- Return type:
List[Dict]