ecoscope.io.raster ================== .. py:module:: ecoscope.io.raster Module Contents --------------- .. py:data:: logger .. py:data:: RioPixelType .. py:class:: RasterExtent(x_min = 33.0, x_max = 37.0, y_min = 2.0, y_max = -2.0) .. py:attribute:: x_min :value: 33.0 .. py:attribute:: x_max :value: 37.0 .. py:attribute:: y_min :value: 2.0 .. py:attribute:: y_max :value: -2.0 .. py:method:: __repr__() .. py:method:: create_from_origin(pixel_size = 0.5, x_min = 0.0, y_min = 0.0, num_rows = 100, num_columns = 100) :classmethod: .. py:class:: RasterProfile(pixel_size = 1000.0, pixel_dtype = rio.float64, crs = 'EPSG:8857', nodata_value = 0.0, band_count = 1, raster_extent = None) Bases: :py:obj:`collections.UserDict` A class for holding raster properties At present this class is only valid for non-rotated rasters with a north-up orientation and square sized pixels defined by the E-W pixel size .. py:method:: _recompute_transform_(key) Recomputes the affine transformation matrix when the pixel_size or raster_extent value is updated. .. py:method:: __getattr__(name) .. py:method:: __setattr__(name, value) .. py:method:: __setitem__(key, item) .. py:class:: RasterData .. py:attribute:: data :type: numpy.ndarray .. py:attribute:: crs :type: str .. py:attribute:: transform :type: rasterio.Affine .. py:method:: from_raster_file(raster_path) :classmethod: .. py:class:: RasterPy .. py:method:: write(ndarray, fp, columns, rows, band_count, driver = 'GTiff', dtype = rio.float64, crs = None, transform = None, nodata = None, sharing = False, indexes = 1, **kwargs) :classmethod: .. py:method:: read(fp, driver = None, **kwargs) :classmethod: .. py:method:: read_write(fp, driver = None, **kwargs) :classmethod: .. py:function:: reduce_region(gdf, raster_path_list, reduce_func) A function to apply the reduce_func to the values of the pixels within each of the rasters for every shape within the input geopandas dataframe 'geometry' column :param gdf: geopandas dataframe. The geometry column will be used to mask the areas of the input raster to be used in the reduction :param raster_path_list: a list of raster files on disc to analyse :param reduce_func: a single-value function to apply to the values of the input raster :return: dataframe with a column of reduce values for each raster and a row for each region .. py:function:: raster_to_gdf(raster_path) .. py:function:: grid_to_raster(grid, xlen, ylen, val_column = '', out_dir = '', raster_name = None) Save a GeoDataFrame grid to a raster. Args: grid (gpd.GeoDataFrame): The grid to rasterize xlen (int): The width of the raster cells, units must be valid in the CRS of the provided grid ylen (int): The height of the raster cells, units must be valid in the CRS of the provided grid val_column (str): The dataframe column of values to fill the raster cells out_dir (str): The directory to save the raster to - inert if raster_name is not provided raster_name (str): The filename name of the output raster Returns: A rio.MemoryFile if raster_name is provided .. py:function:: raster_to_grid(raster_path) .. py:function:: get_crs(raster_path)