An on-demand geospatial compute engine.
Dynamic Compute
Dynamic-Compute is a map computation engine. It enables users to dynamically generate maps from a composable set of Python operations. Together, these properties enable data scientists in the building of complex GIS applications.
The Dynamic Compute API can be found as Python package earthdaily-earthone-dynamic-compute, and can be imported as earthdaily.earthone.dynamic_compute.
- class Mosaic(graft, bands=None, product_id=None, start_datetime=None, end_datetime=None, image_ids=None)
Class wrapper around mosaic operations
- argmax(axis)
Apply np.ma.argmax to the ComputeMap
- Parameters:
axis – (str) Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”]. If called on an ImageStack, must be in [“bands”, “images”]
- Returns:
Mosaic
- argmin(axis)
Apply np.ma.argmin to the ComputeMap
- Parameters:
axis – (str) Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”]. If called on an ImageStack, must be in [“bands”, “images”]
- Returns:
Mosaic
- aspect(resolution_x=None, resolution_y=None)
Compute the aspect of the mosaic
- Returns:
Mosaic object with the aspect
- Return type:
- clip(lo, hi)
Generate a new Mosaic that is bounded by low and hi.
- Parameters:
lo (Number) – Lower bound
hi (Number) – Upper bound
- Returns:
bounded – New Mosaic object that is bounded
- Return type:
- compute(aoi, **kwargs)
Evaluate this ComputeMap for a particular AOI
- Parameters:
aoi (earthdaily.earthone.geo.GeoContext) – GeoContext for which to compute evaluate this ComputeMap
- Returns:
results – Evaluation of self for this AOI. The return will be either an array, properties as a list, properties as dict, or both as a DotDict
- Return type:
Union[Array, List, Dict, DotDict]
- concat_bands(other)
Create a new Mosaic that stacks bands. This call does not mutate this
- filled(fill_val)
Generate a new Mosaic that has masked values filled with specified value.
- Parameters:
fill_val (Number) – value to fill masked pixels
- Returns:
bounded – New Mosaic object that is bounded
- Return type:
- classmethod from_image_ids(image_ids, bands, **kwargs)
Create a new Mosaic object from a list of image IDs
- Parameters:
image_ids (list) – List of image IDs for the images that will be mosaicked
bands (Union[str, List[str]]) – A space-separated list of bands within the product, or a list of strings.
- Returns:
m – New mosaic object.
- Return type:
- classmethod from_product_bands(product_id, bands, start_datetime=None, end_datetime=None, **kwargs)
Create a new Mosaic object
- Parameters:
product_id (str) – ID of the product from which we want to access data
bands (Union[str, List[str]]) – A space-separated list of bands within the product, or a list of strings.
start_datetime (Optional[Union[str, datetime.date, datetime.datetime]) – Start date for mosaic
end_datetime (Optional[Union[str, datetime.date, datetime.datetime]) – End date for mosaic
- Returns:
m – New mosaic object.
- Return type:
- gradient_x(resolution=None)
Compute the gradient in the x (E-W) direction
- Returns:
Mosaic object with the E-W gradient
- Return type:
- gradient_y(resolution=None)
Compute the gradient in the y (N-S) direction
- Returns:
Mosaic object with the N-S gradient
- Return type:
- mask(mask)
Apply a mask as a delayed object. This call does not mutate this
- Parameters:
mask (ComputeMap) – Delayed object to use as a mask.
- Returns:
masked – Masked mosaic.
- Return type:
- max(axis)
Apply np.ma.max to the ComputeMap
- Parameters:
axis (str) – Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”].
- Returns:
ComputeMap
- mean(axis)
Apply np.ma.mean to the ComputeMap
- Parameters:
axis (str) – Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”].
- Returns:
ComputeMap
- median(axis)
Apply np.ma.median to the ComputeMap
- Parameters:
axis (str) – Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”].
- Returns:
ComputeMap
- min(axis)
Apply np.ma.min to the ComputeMap
- Parameters:
axis (str) – Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”].
- Returns:
ComputeMap
- pick_bands(bands)
Create a new Mosaic object with the specified bands and the product-id of this Mosaic object
- Parameters:
bands (str) – A space-separated list of bands within the product, or a list of bands as strings
- Returns:
m – New mosaic object.
- Return type:
- reduce(reducer, axis='bands')
Call a reduction function on this Mosaic
- Parameters:
reducer (Callable) – function to reduce Mosaic
axis (str) – Axis over which to call the reducer, must be in [“bands”].
- Raises:
NotImplementedError – axis must be bands
- Returns:
Mosaic
- rename_bands(bands)
Rename the bands of an array.
- slope(resolution_x=None, resolution_y=None)
Compute the slope of the mosaic
- Returns:
Mosaic object with the slope
- Return type:
- std(axis)
Apply np.ma.std to the ComputeMap
- Parameters:
axis (str) – Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”].
- Returns:
ComputeMap
- sum(axis)
Apply np.ma.sum to the ComputeMap
- Parameters:
axis (str) – Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”].
- Returns:
ComputeMap
- tile_layer(name=None, scales=None, colormap=None, checkerboard=True, classes=None, val_range=None, alpha=None, log_level=10, **parameter_overrides)
A .DynamicComputeLayer for this Mosaic.
Generally, use Mosaic.visualize for displaying on map. Only use this method if you’re managing your own ipyleaflet Map instances, and creating more custom visualizations.
An empty Mosaic will be rendered as a checkerboard (default) or blank tile.
- Parameters:
name (str) – The name of the layer.
scales (list of lists, default None) –
The scaling to apply to each band in the Mosaic.
If Mosaic contains 3 bands,
scales
must be a list like[(0, 1), (0, 1), (-1, 1)]
.If Mosaic contains 1 band,
scales
must be a list like[(0, 1)]
, or just(0, 1)
for convenienceIf None, each 256x256 tile will be scaled independently. based on the min and max values of its data.
colormap (str, default None) –
- The name of the colormap to apply to the Mosaic. Only valid if the
Mosaic has a single band.
classes (list, default None) – Whether or not there are classes in the layer, indicating it is classified
checkerboard (bool, default True) – Whether to display a checkerboarded background for missing or masked data.
log_level (int, default logging.DEBUG) –
Only listen for log records at or above this log level during tile computation. See https://docs.python.org/3/library/logging.html#logging-levels
for valid log levels.
**parameter_overrides (JSON-serializable value, Proxytype, or ipywidgets.Widget) –
Values—or ipywidgets—for any parameters that this Mosaic depends on.
If this Mosaic depends on
dc.widgets
, you don’t have to pass anything for those—any widgets it depends on are automatically linked to the layer. However, you can override their current values (or widgets) by passing new values (or ipywidget instances) here.Values can be given as Proxytypes, or as Python objects like numbers, lists, and dicts that can be promoted to them. These arguments cannot depend on any parameters.
If an
ipywidgets.Widget
is given, it’s automatically linked, so updating the widget causes the argument value to change, and the layer to update.Once these initial argument values are set, they can be modified by assigning to ~.DynamicComputeLayer.parameters on the returned DynamicComputeLayer.
For more information, see the docstring to ParameterSet.
- Returns:
layer
- Return type:
.DynamicComputeLayer
- unpack_bands(bands)
Create a tuple of new Mosaic objects with one for each bands.
- Parameters:
bands (str) – A space-separated list of bands within the product.
- Returns:
m – New mosaic object per band passed in.
- Return type:
Tuple[Mosaic, …]
- update_resampler(resampler)
Create a new mosaic object with an updated resampler
- Parameters:
resampler (eo.catalog.ResampleAlgorithm) – New resampler algorithm
- Returns:
updated_mosaic – Mosaic with updated resampling
- Return type:
- visualize(name, map, colormap=None, scales=None, checkerboard=True, classes=None, val_range=False, alpha=None, **parameter_overrides)
Visualize this Mosaic instance on a map. This call does not mutate this :param name: Name of this layer on the map :type name: str :param map: IPyleaflet map on which to add this mosaic as a layer :type map: ipyleaflet.leaflet.Map :param colormap: Optional colormap to use :type colormap: str :param scales: List of lists where each sub-list is a lower and upper bound. There must be
as many sub-lists as bands in the mosaic
- Parameters:
classes (list, default None) – Whether or not there are classes in the layer, indicating it is classified
- Returns:
layer – IPyleaflet tile layer on the map.
- Return type:
lyr
- class ImageStack(full_graft, bands=None, product_id=None, start_datetime=None, end_datetime=None, pad=0, resampler=ResampleAlgorithm.NEAR, predicate_filter=None, sort_by=None, ascending=None)
- argmax(axis)
Apply np.ma.argmax to the ComputeMap
- Parameters:
axis – (str) Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”]. If called on an ImageStack, must be in [“bands”, “images”]
- Returns:
Mosaic
- argmin(axis)
Apply np.ma.argmin to the ComputeMap
- Parameters:
axis – (str) Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”]. If called on an ImageStack, must be in [“bands”, “images”]
- Returns:
Mosaic
- clip(lo, hi)
Generate a new ImageStack that is bounded by low and hi.
- Parameters:
lo (Number) – Lower bound
hi (Number) – Upper bound
- Returns:
bounded – New ImageStack object that is bounded
- Return type:
- compute(aoi, **kwargs)
Evaluate this ComputeMap for a particular AOI
- Parameters:
aoi (earthdaily.earthone.geo.GeoContext) – GeoContext for which to compute evaluate this ComputeMap
- Returns:
results – Evaluation of self for this AOI. The return will be either an array, properties as a list, properties as dict, or both as a DotDict
- Return type:
Union[Array, List, Dict, DotDict]
- concat_bands(other)
Create a new ImageStack that stacks bands. This call does not mutate this
Note that per-image metadata for the returned ImageStack instance is taken from self not other.
- Parameters:
other (ImageStack) – concat the bands of this ImageStack with those of other
- Returns:
stack – ImageStack object with stacked bands
- Return type:
- filled(fill_val)
Generate a new ImageStack that has masked values filled with specified value.
- Parameters:
fill_val (Number) – value to fill masked pixels
- Returns:
filled – New ImageStack object that is filled
- Return type:
- filter(pred)
Filter an image stack to based on image properties.
- Parameters:
pred (eo.catalog.properties.OpExpression) – Predicate for image selection
- Returns:
New ImageStack object.
- Return type:
- filter_by_id(id_list)
Filter an image stack to based on image properties.
- Parameters:
id_list (List[str]) – List of image ids.
- Returns:
New ImageStack object.
- Return type:
- classmethod from_product_bands(product_id, bands, start_datetime, end_datetime, predicate_filter=None, sort_by=None, ascending=True, **kwargs)
Create a new ImageStack object
- Parameters:
product_id (str) – ID of the product from which we want to access data
bands (Union[str, List[str]]) – A space-separated list of bands within the product, or a list of strings.
start_datetime (Union[str, datetime.date, datetime.datetime]) – Start date for image stack
end_datetime (Union[str, datetime.date, datetime.datetime]) – End date for image stack
predicate_filter (eo.catalog.properties.OpExpression) – Optional kwarg that allows filtering of scenes prior to creating the ImageStack. The benefit of using this over the .filter() method is that it allows filtering of metadata before an ImageCollection is created, which allows less data to be requested from platform. The downside is this filter cannot be changed without changing the ImageStack object.
sort_by (str) – Optional kwarg that allows for sorting of images. Follows the same logic as sorting for catalog. See for more details: https://docs.earthdaily.earthone.com/earthdaily.earthone/catalog/docs/image.html
ascending (bool) – Optional kwarg that is used in sorting. Defaults to True. If sort_by is not provided, this kwarg will be ignored.
- Returns:
m – New ImageStack object.
- Return type:
- groupby(grouping_func)
Perform a grouping function over either images or bands and return an ImageStackGroupBy object.
- Parameters:
grouping_func (Callable[[dict], Hashable]) – Function to pick out the values to group by. The function should take as input a dotted-dict representing metadata for an image and should return a hashable value upon which groups will be build.
- Return type:
ImageStackGroupBy object.
Example
>>> import earthdaily.earthone.dynamic_compute as dc >>> m = dc.map >>> m >>> sigma0_vv = dc.ImageStack.from_product_bands( "esa:sentinel-1:sigma0v:v1", "vv", "20230101", "20230401" ) >>> # group by acquired month >>> grouped_sigma = sigma0_vv.groupby(lambda x: x.acquired.month) >>> # loop through each grouping, applying a max reducer and visualize it on the map >>> for group_name, image_stack in grouped_sigma.groups.compute(m.geocontext()): image_stack.max(axis="images").visualize(str(group_name), m, colormap="turbo")
- length()
Proxy object for the length of this image stack
- Returns:
compute_map – Proxy object for the length
- Return type:
ComputeMap
- mask(mask)
Apply a mask as a delayed object. This call does not mutate this
- Parameters:
mask (ComputeMap) – Delayed object to use as a mask.
- Returns:
masked – Masked mosaic.
- Return type:
- max(axis)
Apply np.ma.max to the ComputeMap
- Parameters:
axis (str) – Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”].
- Returns:
ComputeMap
- mean(axis)
Apply np.ma.mean to the ComputeMap
- Parameters:
axis (str) – Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”].
- Returns:
ComputeMap
- median(axis)
Apply np.ma.median to the ComputeMap
- Parameters:
axis (str) – Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”].
- Returns:
ComputeMap
- min(axis)
Apply np.ma.min to the ComputeMap
- Parameters:
axis (str) – Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”].
- Returns:
ComputeMap
- pick_bands(bands)
Create a new ImageStack object with the specified bands and the product-id of this ImageStack object
- Parameters:
bands (str) – A space-separated list of bands within the product, or a list of bands as strings
- Returns:
m – New mosaic object.
- Return type:
- reduce(reducer, axis='images')
Perform a reduction over either images or bands. Note that this does not mutate self.
- Parameters:
reducer (Callable[[np.ndarray], np.ndarray]) – Function to perform the reduction
axis (str) – Axis over which to reduce, either “bands” or “images”
- Returns:
new_obj – Reduced object, either a Mosaic if axis is “images” or an ImageStack if axis is “bands”
- Return type:
Union[Mosaic, ImageStack]
- rename_bands(bands)
Rename the bands of an array.
- std(axis)
Apply np.ma.std to the ComputeMap
- Parameters:
axis (str) – Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”].
- Returns:
ComputeMap
- sum(axis)
Apply np.ma.sum to the ComputeMap
- Parameters:
axis (str) – Axis over which to call the reducer. If called on a Mosaic, must be in [“bands”].
- Returns:
ComputeMap
- unpack_bands(bands)
Create a tuple of new ImageStack objects with one for each bands.
- Parameters:
bands (str) – A space-separated list of bands within the product.
- Returns:
m – New mosaic object per band passed in.
- Return type:
Tuple[ImageStack, …]
- update_resampler(resampler)
Create a new mosaic object with an updated resampler
- Parameters:
resampler (eo.catalog.ResampleAlgorithm) – New resampler algorithm
- Returns:
updated_mosaic – Mosaic with updated resampling
- Return type: