:py:mod:`statgis.gee.zonal_statistics` ====================================== .. py:module:: statgis.gee.zonal_statistics .. autoapi-nested-parse:: Reduce images in a region of interest Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: statgis.gee.zonal_statistics.zonal_statistics_image statgis.gee.zonal_statistics.zonal_statistics_collection .. py:function:: zonal_statistics_image(image: ee.Image, geom: ee.Geometry, scale: float, bands: Union[Sequence[str], str] = 'all', reducer: Union[ee.Reducer, str] = 'all', tile_scale: int = 16) -> pandas.DataFrame Function to calculate a statistic in the specified region for one image. :param image: Image of interest. :type image: ee.Image :param geom: Region of interest to reduce the image. :type geom: ee.Geometry :param scale: Pixel size for the sample to perform the zonal statistics. :type scale: float :param bands: List, tuple with the bands of interest or, if you only want one band, the name of the band. By default, the process takes into consideration all bands. :type bands: Sequence | str (optional) :param reducer: Reducer to apply to the image. By default, image are reduced to its, mean, standard deviation, maximum, minimum, and count. :type reducer: ee.Reducer | str (optional) :param tile_scale: Scale of the mosaic to allow EarthEngine to split the task to more cores. :type tile_scale: int (optional) :returns: **data** -- DataFrame with all the stats for all specified bands. :rtype: pandas.DataFrame .. rubric:: Example >>> import ee >>> from statgis.gee import zonal_statistics >>> ee.Initialize() >>> roi = ee.Geometry.BBox(-75.2671803, 4.4104561 ,-75.2691803, 4.4124561) >>> mean_precipitation_2022 = ( ... ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY") ... .filterDate("2022-01-01", "2022-12-31") ... .mean() ... ) >>> stats = zonal_statistics.zonal_statistics_image(mean_precipitation_2022, roi, 30, "precipitation") .. py:function:: zonal_statistics_collection(image_collection: ee.ImageCollection, geom: ee.Geometry, scale: float, bands: Union[Sequence[str], str] = 'all', reducer: Union[ee.Reducer, str] = 'all', tile_scale: int = 16) -> pandas.DataFrame Function to calculate a statistic in the specified region for all Image in an image collection. :param image_collection: Image Collection with the image to reduce. :type image_collection: ee.ImageCollection :param geom: Region of interest to reduce the images. :type geom: ee.Geometry :param scale: Pixel size for the sample to perform the zonal statistics. :type scale: float :param bands: List, tuple with the bands of interest or, if you only want one band, the name of the band. By default, the process takes into consideration all bands. :type bands: Sequence | str (optional) :param reducer: Reducer to apply to all image. By default, image are reduced to its, mean, standard deviation, maximum, minimum, and count. :type reducer: ee.Reducer | str (optional) :param tile_scale: Scale of the mosaic to allow EarthEngine to split the task to more cores. :type tile_scale: int (optional) :returns: **data** -- DataFrame with all the stats for all specified bands. :rtype: pandas.DataFrame .. rubric:: Example >>> import ee >>> from statgis.gee import zonal_statistics >>> ee.Initialize() >>> roi = ee.Geometry.BBox(-75.2671803, 4.4104561 ,-75.2691803, 4.4124561) >>> chirps = ee.ImageCollection("UCSB-CHG/CHIRPS/DAILY").filterDate("2022-01-01", "2022-12-31") >>> daily_mean_precipitation = zonal_statistics.zonal_statistics_collection( ... chirps, roi, 30, "precipitation", ee.Reducer.mean() ... )