ARD Monitoring¶
The ARD Monitoring API allows you to subscribe to persistent searches for imagery. When a new image is acquired that matches your search criteria you can be notified by email or via Amazon SNS.
For more information see the Monitoring API User Guide
Creating a new monitor is similar to creating Selects and Orders. Notifications take either a bounding box or geometry object over which to watch, and a query dictionary for filter queries. In the Select tutorial we searched for imagery over Albuequerque, here we'll set up an identical monitor:
from max_ard import Monitor
bbox = [-106.8, 35.1, -106.4, 35.4]
query = {
"platform": {
"eq": "worldview-02"
},
"aoi:cloud_free_percentage": {
"gte": 95
},
"aoi:data_percentage": {
"gte": 75
}
}
monitor = Monitor(bbox=bbox, query=query)
#optionally, give the monitor a name and/or description
monitor = Monitor(bbox=bbox, query=query, name="My Monitor", description="Albuquerque Example")
You can add notifications in the same matter as Order objects:
monitor.add_email_notification(<your email>)
monitor.add_sns_notification(<your topic ARN>)
Then submit
the Monitor to the service:
monitor.submit()
You can deactivate a Monitor by using the delete
method. This is a "soft" delete and sets the monitor to be inactive.
monitor.delete()
For troubleshooting, you can retrieve a monitor's history in case you suspect your notifications are not getting through. Note that you do not need to use this to poll the monitor - the system will send you a notification.
monitor.get_history()
To list active monitors in your account, use:
Monitor.list_monitors()
You can also retrieve a monitor by its ID:
Monitor.from_id(<id>)
Monitors have the following useful attributes:
.monitor_id
: ID of the monitor.name
: Name of the monitor, if used.description
: Description of the monitor, if used.cell_ids
: List of the ARD Grid cells the monitor is watching.cells
:maxar_canvas_grid
Cell objects for the watched cells.query
: Query used to filter new acquisitions
Monitor objects also support the Python Geospatial Protocol and return a MultiPolygon of the monitored cells.
from shapely.geometry import shape
shape(monitor)