cartoee API¶
This page provides an overview of cartoee’s API. For detailed examples using the package please refer to the documentation on the docs page.
-
cartoee.plotting.
addColorbar
(ax, loc=None, visParams=None, discrete=False, **kwargs)¶ Add a colorbar tp the map based on visualization parameters provided
Parameters: - ax (cartopy.mpl.geoaxes.GeoAxesSubplot | cartopy.mpl.geoaxes.GeoAxes) – required cartopy GeoAxesSubplot object to add image overlay to
- loc (str, optional) – string specifying the position
- visParams (dict, optional) – visualization parameters as a dictionary. See https://developers.google.com/earth-engine/image_visualization for options
- **kwargs – remaining keyword arguments are passed to colorbar()
Returns: matplotlib colorbar object
Return type: cb (matplotlib.colorbar.ColorbarBase)
Raises: - Warning – If ‘discrete’ is true when “palette” key is not in visParams
- ValueError – If ax is not of type cartopy.mpl.geoaxes.GeoAxesSubplot
- ValueError – If ‘cmap’ or “palette” key in visParams is not provided
- ValueError – If “min” in visParams is not of type scalar
- ValueError – If “max” in visParams is not of type scalar
- ValueError – If ‘loc’ or ‘cax’ keywords are not provided
- ValueError – If ‘loc’ is not of type str or does not equal available options
-
cartoee.plotting.
addLayer
(imgObj, ax, dims=None, region=None, cmap=None, visParams=None)¶ Add an Earth Engine image to a cartopy plot.
Parameters: - imgObj (ee.image.Image) – Earth Engine image result to plot.
- ax (cartopy.mpl.geoaxes.GeoAxesSubplot | cartopy.mpl.geoaxes.GeoAxes) – required cartopy GeoAxesSubplot object to add image overlay to
- dims (list | tuple | int, optional) – dimensions to request earth engine result as [WIDTH,HEIGHT]. If only one number is passed, it is used as the maximum, and the other dimension is computed by proportional scaling. Default None and infers dimesions
- region (list | tuple, optional) – geospatial region of the image to render in format [E,S,W,N]. By default, the whole image
- cmap (str, optional) – string specifying matplotlib colormap to colorize image. If cmap is specified visParams cannot contain ‘palette’ key
- visParams (dict, optional) – visualization parameters as a dictionary. See https://developers.google.com/earth-engine/image_visualization for options
Returns: cartopy GeoAxesSubplot object with Earth Engine results displayed
Return type: ax (cartopy.mpl.geoaxes.GeoAxesSubplot)
Raises: - ValueError – If dims is not of type list, tuple, or int
- ValueError – If imgObj is not of type ee.image.Image
- ValueError – If ax if not of type cartopy.mpl.geoaxes.GeoAxesSubplot ‘
-
cartoee.plotting.
buildPalette
(cmap, n=256)¶ Creates hex color code palette from a matplotlib colormap
Parameters: - cmap (str) – string specifying matplotlib colormap to colorize image. If cmap is specified visParams cannot contain ‘palette’ key
- n (int, optional) – Number of hex color codes to create from colormap. Default is 256
Returns: list of hex color codes from matplotlib colormap for n intervals
Return type: palette (list)
-
cartoee.plotting.
getMap
(imgObj, proj=<cartopy.crs.PlateCarree object>, **kwargs)¶ Wrapper function to create a new cartopy plot with project and adds Earth Engine image results
Parameters: - imgObj (ee.image.Image) – Earth Engine image result to plot
- proj (cartopy.crs, optional) – Cartopy projection that determines the projection of the resulting plot. By default uses an equirectangular projection, PlateCarree
- **kwargs – remaining keyword arguments are passed to addLayer()
Returns: cartopy GeoAxesSubplot object with Earth Engine results displayed
Return type: ax (cartopy.mpl.geoaxes.GeoAxesSubplot)