ipygee ====== .. py:module:: ipygee .. autoapi-nested-parse:: The init file of the package. Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/ipygee/asset/index /autoapi/ipygee/decorator/index /autoapi/ipygee/ee_feature_collection/index /autoapi/ipygee/ee_image/index /autoapi/ipygee/ee_image_collection/index /autoapi/ipygee/map/index /autoapi/ipygee/plotting/index /autoapi/ipygee/sidecar/index /autoapi/ipygee/task/index /autoapi/ipygee/type/index Attributes ---------- .. autoapisummary:: ipygee.__author__ ipygee.__email__ ipygee.__version__ Classes ------- .. autoapisummary:: ipygee.FeatureCollectionAccessor ipygee.ImageAccessor ipygee.ImageCollectionAccessor Package Contents ---------------- .. py:class:: FeatureCollectionAccessor(obj) Initialize the FeatureCollectionAccessor class. .. py:method:: plot_by_features(type = 'bar', featureId = 'system:index', properties = None, labels = None, colors = None, figure = None, **kwargs) Plot the values of a :py:class:`ee.FeatureCollection` by feature. Each feature property selected in properties will be plotted using the ``featureId`` as the x-axis. If no ``properties`` are provided, all properties will be plotted. If no ``featureId`` is provided, the ``"system:index"`` property will be used. .. warning:: This function is a client-side function. :param type: The type of plot to use. Defaults to ``"bar"``. can be any type of plot from the python lib ``matplotlib.pyplot``. If the one you need is missing open an issue! :param featureId: The property to use as the x-axis (name the features). Defaults to ``"system:index"``. :param properties: A list of properties to plot. Defaults to all properties. :param labels: A list of labels to use for plotting the properties. If not provided, the default labels will be used. It needs to match the properties' length. :param colors: A list of colors to use for plotting the properties. If not provided, the default colors from the matplotlib library will be used. :param figure: The bokeh figure to plot the data on. If None, a new figure is created. :param kwargs: Additional arguments from the ``pyplot`` type selected. .. rubric:: Examples .. jupyter-execute:: import ee, geetools from geetools.utils import initialize_documentation from matplotlib import pyplot as plt initialize_documentation() # start a plot object from matplotlib library fig, ax = plt.subplots(figsize=(10, 5)) # plot on this object the 10 first items of the FAO GAUL level 2 feature collection # for each one of them (marked with it's "ADM0_NAME" property) we plot the value of the "ADM1_CODE" and "ADM2_CODE" properties fc = ee.FeatureCollection("FAO/GAUL/2015/level2").limit(10) fc.geetools.plot_by_features(featureId="ADM2_NAME", properties=["ADM1_CODE", "ADM2_CODE"], colors=["#61A0D4", "#D49461"], ax=ax) # Modify the rotation of existing x-axis tick labels for label in ax.get_xticklabels(): label.set_rotation(45) .. py:method:: plot_by_properties(type = 'bar', featureId = 'system:index', properties = None, labels = None, colors = None, figure = None, **kwargs) Plot the values of a :py:class:`ee.FeatureCollection` by property. Each features will be represented by a color and each property will be a bar of the bar chart. .. warning:: This function is a client-side function. :param type: The type of plot to use. Defaults to ``"bar"``. can be any type of plot from the python lib ``matplotlib.pyplot``. If the one you need is missing open an issue! :param featureId: The property to use as the y-axis (name the features). Defaults to ``"system:index"``. :param properties: A list of properties to plot. Defaults to all properties. :param labels: A list of labels to use for plotting the properties. If not provided, the default labels will be used. It needs to match the properties' length. :param colors: A list of colors to use for plotting the properties. If not provided, the default colors from the matplotlib library will be used. :param figure: The bokeh figure to plot the data on. If None, a new figure is created. :param kwargs: Additional arguments from the ``pyplot`` function. .. rubric:: Examples .. jupyter-execute:: import ee, ipygee from geetools.utils import initialize_documentation from matplotlib import pyplot as plt initialize_documentation() # start a plot object from matplotlib library fig, ax = plt.subplots(figsize=(10, 5)) # plot on this object the 10 first items of the FAO GAUL level 2 feature collection # for each one of them (marked with it's "ADM2_NAME" property) we plot the value of the "ADM1_CODE" property fc = ee.FeatureCollection("FAO/GAUL/2015/level2").limit(10) fc.bokeh.plot_by_properties(featureId="ADM2_NAME", properties=["ADM1_CODE"], ax=ax) .. py:method:: plot_hist(property, label = '', figure = None, color = None, **kwargs) Plot the histogram of a specific property. .. warning:: This function is a client-side function. :param property: The property to display :param label: The label to use for the property. If not provided, the property name will be used. :param figure: The bokeh figure to plot the data on. If None, a new figure is created. :param color: The color to use for the plot. If not provided, the default colors from the matplotlib library will be used. :param \*\*kwargs: Additional arguments from the :py:func:`matplotlib.pyplot.hist` function. .. rubric:: Examples .. jupyter-execute:: import ee, ipygee from geetools.utils import initialize_documentation from matplotlib import pyplot as plt initialize_documentation() # start a plot object from matplotlib library fig, ax = plt.subplots(figsize=(10, 5)) ax.set_title('Histogram of Precipitation in July') ax.set_xlabel('Precipitation (mm)') # build the histogram of the precipitation band for the month of july in the PRISM dataset normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm81m').toBands() region = ee.Geometry.Rectangle(-123.41, 40.43, -116.38, 45.14) climSamp = normClim.sample(region, 5000) climSamp.ipygee.plot_hist("07_ppt", ax=ax, bins=20) fig.show() .. py:attribute:: _obj .. py:class:: ImageAccessor(obj) Initialize the Image class. .. py:method:: plot_by_bands(type, regions, reducer = 'mean', bands = None, regionId = 'system:index', labels = None, colors = None, figure = None, scale = 10000, crs = None, crsTransform = None, tileScale = 1) Plot the reduced values for each band. Each band will be plotted using the ``labels`` as x-axis label defaulting to band names if not provided. If no ``bands`` are provided, all bands will be plotted. If no ``regionId`` are provided, the ``"system:index"`` property will be used. .. warning:: This method is client-side. :param type: The type of plot to use. Defaults to ``"bar"``. can be any type of plot from the python lib ``matplotlib.pyplot``. If the one you need is missing open an issue! :param regions: The regions to compute the reducer in. :param reducer: The name of the reducer or a reducer object to use. Default is ``"mean"``. :param bands: The bands to compute the reducer on. Default to all bands. :param regionId: The property used to label region. Defaults to ``"system:index"``. :param labels: The labels to use for the output dictionary. Default to the band names. :param colors: The colors to use for the plot. Default to the default matplotlib colors. :param figure: The bokeh figure to plot the data on. If None, a new figure is created. :param scale: The scale to use for the computation. Default is 10000m. :param crs: The projection to work in. If unspecified, the projection of the image's first band is used. If specified in addition to scale, rescaled to the specified scale. :param crsTransform: The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with 'scale', and replaces any transform already set on the projection. :param tileScale: A scaling factor between 0.1 and 16 used to adjust aggregation tile size; setting a larger tileScale (e.g., 2 or 4) uses smaller tiles and may enable computations that run out of memory with the default. :returns: The bokeh figure with the plot .. rubric:: Examples .. code-block:: python import ee, ipygee ee.Initialize() ecoregions = ee.FeatureCollection("projects/google/charts_feature_example").select(["label", "value","warm"]) normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm91m').toBands() normClim.bokeh.plot_by_bands(ecoregions, ee.Reducer.mean(), scale=10000) .. py:method:: plot_by_regions(type, regions, reducer = 'mean', bands = None, regionId = 'system:index', labels = None, colors = None, figure = None, scale = 10000, crs = None, crsTransform = None, tileScale = 1) Plot the reduced values for each region. Each region will be plotted using the ``regionId`` as x-axis label defaulting to "system:index" if not provided. If no ``bands`` are provided, all bands will be plotted. If no ``labels`` are provided, the band names will be used. .. warning:: This method is client-side. :param type: The type of plot to use. Defaults to ``"bar"``. can be any type of plot from the python lib ``matplotlib.pyplot``. If the one you need is missing open an issue! :param regions: The regions to compute the reducer in. :param reducer: The name of the reducer or a reducer object to use. Default is ``"mean"``. :param bands: The bands to compute the reducer on. Default to all bands. :param regionId: The property used to label region. Defaults to ``"system:index"``. :param labels: The labels to use for the output dictionary. Default to the band names. :param colors: The colors to use for the plot. Default to the default matplotlib colors. :param figure: The bokeh figure to plot the data on. If None, a new figure is created. :param scale: The scale to use for the computation. Default is 10000m. :param crs: The projection to work in. If unspecified, the projection of the image's first band is used. If specified in addition to scale, rescaled to the specified scale. :param crsTransform: The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with 'scale', and replaces any transform already set on the projection. :param tileScale: A scaling factor between 0.1 and 16 used to adjust aggregation tile size; setting a larger tileScale (e.g., 2 or 4) uses smaller tiles and may enable computations that run out of memory with the default. :returns: The bokeh figure with the plot. .. rubric:: Examples .. code-block:: python import ee, ipygee ee.Initialize() ecoregions = ee.FeatureCollection("projects/google/charts_feature_example").select(["label", "value","warm"]) normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm91m').toBands() normClim.bokeh.plot_by_regions(ecoregions, ee.Reducer.mean(), scale=10000) .. py:method:: plot_hist(bins = 30, region = None, bands = None, labels = None, colors = None, precision = 2, figure = None, scale = 10000, crs = None, crsTransform = None, bestEffort = False, maxPixels = 10**7, tileScale = 1, **kwargs) Plot the histogram of the image bands. :param bins: The number of bins to use for the histogram. Default is 30. :param region: The region to compute the histogram in. Default is the image geometry. :param bands: The bands to plot the histogram for. Default to all bands. :param labels: The labels to use for the output dictionary. Default to the band names. :param colors: The colors to use for the plot. Default to the default matplotlib colors. :param precision: The number of decimal to keep for the histogram bins values. Default is 2. :param figure: The bokeh figure to plot the data on. If None, a new figure is created. :param scale: The scale to use for the computation. Default is 10,000m. :param crs: The projection to work in. If unspecified, the projection of the image's first band is used. If specified in addition to scale, rescaled to the specified scale. :param crsTransform: The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with 'scale', and replaces any transform already set on the projection. :param bestEffort: If the polygon would contain too many pixels at the given scale, compute and use a larger scale which would allow the operation to succeed. :param maxPixels: The maximum number of pixels to reduce. default to 10**7. :param tileScale: A scaling factor between 0.1 and 16 used to adjust aggregation tile size; setting a larger tileScale (e.g., 2 or 4) uses smaller tiles and may enable computations that run out of memory with the default. :param \*\*kwargs: Keyword arguments passed to the `matplotlib.fill_between() `_ function. :returns: The bokeh figure with the plot. .. rubric:: Examples .. code-block:: python import ee, ipygee ee.Initialize() normClim = ee.ImageCollection('OREGONSTATE/PRISM/Norm91m').toBands() normClim.bokeh.plot_hist() .. py:attribute:: _obj .. py:class:: ImageCollectionAccessor(obj) Initialize the ImageCollectionAccessor class. .. py:method:: plot_dates_by_bands(region, reducer = 'mean', dateProperty = 'system:time_start', bands = None, labels = None, colors = None, figure = None, scale = 10000, crs = None, crsTransform = None, bestEffort = False, maxPixels = 10**7, tileScale = 1) Plot the reduced data for each image in the collection by bands on a specific region. This method is plotting the reduced data for each image in the collection by bands on a specific region. :param region: The region to reduce the data on. :param reducer: The name of the reducer or a reducer object to use. Default is ``"mean"``. :param dateProperty: The property to use as date for each image. Default is ``"system:time_start"``. :param bands: The bands to reduce. If empty, all bands are reduced. :param labels: The labels to use for the bands. If empty, the bands names are used. :param colors: The colors to use for the bands. If empty, the default colors are used. :param figure: The bokeh figure to plot the data on. If None, a new figure is created. :param scale: The scale in meters to use for the reduction. default is 10000m :param crs: The projection to work in. If unspecified, the projection of the image's first band is used. If specified in addition to scale, rescaled to the specified scale. :param crsTransform: The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with 'scale', and replaces any transform already set on the projection. :param bestEffort: If the polygon would contain too many pixels at the given scale, compute and use a larger scale which would allow the operation to succeed. :param maxPixels: The maximum number of pixels to reduce. Defaults to 1e7. :param tileScale: A scaling factor between 0.1 and 16 used to adjust aggregation tile size; setting a larger tileScale (e.g., 2 or 4) uses smaller tiles and may enable computations that run out of memory with the default. :returns: A bokeh figure with the reduced values for each band and each date. .. rubric:: Examples .. code-block:: python import ee, geetools ee.Initialize() collection = ( ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA") .filterBounds(ee.Geometry.Point(-122.262, 37.8719)) .filterDate("2014-01-01", "2014-12-31") ) region = ee.Geometry.Point(-122.262, 37.8719).buffer(10000) collection.geetools.plot_dates_by_bands(region, "mean", 10000, "system:time_start") .. py:method:: plot_dates_by_regions(band, regions, label = 'system:index', reducer = 'mean', dateProperty = 'system:time_start', colors = None, figure = None, scale = 10000, crs = None, crsTransform = None, tileScale = 1) Plot the reduced data for each image in the collection by regions for a single band. This method is plotting the reduced data for each image in the collection by regions for a single band. :param band: The band to reduce. :param regions: The regions to reduce the data on. :param label: The property to use as label for each region. Default is ``"system:index"``. :param reducer: The name of the reducer or a reducer object to use. Default is ``"mean"``. :param dateProperty: The property to use as date for each image. Default is ``"system:time_start"``. :param colors: The colors to use for the regions. If empty, the default colors are used. :param figure: The bokeh figure to plot the data on. If None, a new figure is created. :param scale: The scale in meters to use for the reduction. default is 10000m :param crs: The projection to work in. If unspecified, the projection of the image's first band is used. If specified in addition to scale, rescaled to the specified scale. :param crsTransform: The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with 'scale', and replaces any transform already set on the projection. :param tileScale: A scaling factor between 0.1 and 16 used to adjust aggregation tile size; setting a larger tileScale (e.g., 2 or 4) uses smaller tiles and may enable computations that run out of memory with the default. :returns: A bokeh figure with the reduced values for each region and each date. .. rubric:: Examples .. code-block:: python import ee, geetools ee.Initialize() collection = ( ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA") .filterBounds(ee.Geometry.Point(-122.262, 37.8719)) .filterDate("2014-01-01", "2014-12-31") ) regions = ee.FeatureCollection([ ee.Feature(ee.Geometry.Point(-122.262, 37.8719).buffer(10000), {"name": "region1"}), ee.Feature(ee.Geometry.Point(-122.262, 37.8719).buffer(20000), {"name": "region2"}) ]) collection.geetools.plot_dates_by_regions("B1", regions, "name", "mean", 10000, "system:time_start") .. py:method:: plot_doy_by_bands(region, spatialReducer = 'mean', timeReducer = 'mean', dateProperty = 'system:time_start', bands = None, labels = None, colors = None, figure = None, scale = 10000, crs = None, crsTransform = None, bestEffort = False, maxPixels = 10**7, tileScale = 1) Plot the reduced data for each image in the collection by bands on a specific region. This method is plotting the reduced data for each image in the collection by bands on a specific region. :param region: The region to reduce the data on. :param spatialReducer: The name of the reducer or a reducer object to use. Default is ``"mean"``. :param timeReducer: The name of the reducer or a reducer object to use. Default is ``"mean"``. :param dateProperty: The property to use as date for each image. Default is ``"system:time_start"``. :param bands: The bands to reduce. If empty, all bands are reduced. :param labels: The labels to use for the bands. If empty, the bands names are used. :param colors: The colors to use for the bands. If empty, the default colors are used. :param figure: The bokeh figure to plot the data on. If None, a new figure is created. :param scale: The scale in meters to use for the reduction. default is 10000m :param crs: The projection to work in. If unspecified, the projection of the image's first band is used. If specified in addition to scale, rescaled to the specified scale. :param crsTransform: The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with 'scale', and replaces any transform already set on the projection. :param bestEffort: If the polygon would contain too many pixels at the given scale, compute and use a larger scale which would allow the operation to succeed. :param maxPixels: The maximum number of pixels to reduce. Defaults to 1e7. :param tileScale: A scaling factor between 0.1 and 16 used to adjust aggregation tile size; setting a larger tileScale (e.g., 2 or 4) uses smaller tiles and may enable computations that run out of memory with the default. :returns: A bokeh figure with the reduced values for each band and each day. .. rubric:: Examples .. code-block:: python import ee, geetools ee.Initialize() collection = ( ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA") .filterBounds(ee.Geometry.Point(-122.262, 37.8719)) .filterDate("2014-01-01", "2014-12-31") ) region = ee.Geometry.Point(-122.262, 37.8719).buffer(10000) collection.geetools.plot_doy_by_bands(region, "mean", "mean", 10000, "system:time_start") .. py:method:: plot_doy_by_regions(band, regions, label = 'system:index', spatialReducer = 'mean', timeReducer = 'mean', dateProperty = 'system:time_start', colors = None, figure = None, scale = 10000, crs = None, crsTransform = None, tileScale = 1) Plot the reduced data for each image in the collection by regions for a single band. This method is plotting the reduced data for each image in the collection by regions for a single band. :param band: The band to reduce. :param regions: The regions to reduce the data on. :param label: The property to use as label for each region. Default is ``"system:index"``. :param spatialReducer: The name of the reducer or a reducer object to use. Default is ``"mean"``. :param timeReducer: The name of the reducer or a reducer object to use. Default is ``"mean"``. :param dateProperty: The property to use as date for each image. Default is ``"system:time_start"``. :param colors: The colors to use for the regions. If empty, the default colors are used. :param figure: The bokeh figure to plot the data on. If None, a new figure is created. :param scale: The scale in meters to use for the reduction. default is 10000m :param crs: The projection to work in. If unspecified, the projection of the image's first band is used. If specified in addition to scale, rescaled to the specified scale. :param crsTransform: The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with 'scale', and replaces any transform already set on the projection. :param tileScale: A scaling factor between 0.1 and 16 used to adjust aggregation tile size; setting a larger tileScale (e.g., 2 or 4) uses smaller tiles and may enable computations that run out of memory with the default. :returns: A bokeh figure with the reduced values for each region and each day. .. rubric:: Examples .. code-block:: python import ee, geetools ee.Initialize() collection = ( ee.ImageCollection("LANDSAT/LC08/C01/T1_TOA") .filterBounds(ee.Geometry.Point(-122.262, 37.8719)) .filterDate("2014-01-01", "2014-12-31") ) regions = ee.FeatureCollection([ ee.Feature(ee.Geometry.Point(-122.262, 37.8719).buffer(10000), {"name": "region1"}), ee.Feature(ee.Geometry.Point(-122.262, 37.8719).buffer(20000), {"name": "region2"}) ]) collection.geetools.plot_doy_by_regions("B1", regions, "name", "mean", "mean", 10000, "system:time_start") .. py:method:: plot_doy_by_seasons(band, region, seasonStart = 1, seasonEnd = 366, reducer = 'mean', dateProperty = 'system:time_start', colors = None, figure = None, scale = 10000, crs = None, crsTransform = None, bestEffort = False, maxPixels = 10**7, tileScale = 1) Plot the reduced data for each image in the collection by years for a single band. This method is plotting the reduced data for each image in the collection by years for a single band. To set the start and end of the season, use the :py:meth:`ee.Date.getRelative` or :py:class:`time.struct_time` method to get the day of the year. :param band: The band to reduce. :param region: The region to reduce the data on. :param seasonStart: The day of the year that marks the start of the season. :param seasonEnd: The day of the year that marks the end of the season. :param reducer: The name of the reducer or a reducer object to use. Default is ``"mean"``. :param dateProperty: The property to use as date for each image. Default is ``"system:time_start"``. :param colors: The colors to use for the regions. If empty, the default colors are used. :param figure: The bokeh figure to plot the data on. If None, a new figure is created. :param scale: The scale in meters to use for the reduction. default is 10000m :param crs: The projection to work in. If unspecified, the projection of the image's first band is used. If specified in addition to scale, rescaled to the specified scale. :param crsTransform: The list of CRS transform values. This is a row-major ordering of the 3x2 transform matrix. This option is mutually exclusive with 'scale', and replaces any transform already set on the projection. :param bestEffort: If the polygon would contain too many pixels at the given scale, compute and use a larger scale which would allow the operation to succeed. :param maxPixels: The maximum number of pixels to reduce. Defaults to 1e7. :param tileScale: A scaling factor between 0.1 and 16 used to adjust aggregation tile size; setting a larger tileScale (e.g., 2 or 4) uses smaller tiles and may enable computations that run out of memory with the default. :returns: A bokeh figure with the reduced values for each year and each day. .. rubric:: Examples .. jupyter-execute:: import ee, geetools from geetools.utils import initialize_documentation initialize_documentation() collection = ( ee.ImageCollection("LANDSAT/LC08/C02/T1_TOA") .filterBounds(ee.Geometry.Point(-122.262, 37.8719)) .filter(ee.Filter.Or( ee.Filter.date("2022-01-01", "2022-12-31"), ee.Filter.date("2016-01-01", "2016-12-31"), )) .map(lambda i: ee.Image(i).addBands( ee.Image(i) .normalizedDifference(["B5", "B4"]) .rename("NDVI") )) ) collection.geetools.plot_doy_by_seasons( band = "NDVI", region = ee.Geometry.Point(-122.262, 37.8719).buffer(1000), seasonStart = ee.Date("2016-05-01").getRelative("day", "year"), seasonEnd = ee.Date("2016-10-31").getRelative("day", "year"), reducer = "mean", dateProperty = "system:time_start", scale = 10000 ) .. py:attribute:: _obj .. py:data:: __author__ :value: 'Pierrick Rambaud' .. py:data:: __email__ :value: 'pierrick.rambaud49@gmail.com' .. py:data:: __version__ :value: '0.0.0'