You can use a large variety of spatial data to query Earth OnDemand. This page shows you how to use the crowdsourced OpenStreetMap (OSM) to query Earth OnDemand for related imagery. To access OSM data, we will use the osmnx library. There are many ways to access OSM data, and this is useful for datasets like streets, buildings and points of interest.
Import Libraries
import osmnx from earthai.init import *
Retrieve OpenStreetMap Data
We will extract all the libraries in the state of Vermont, USA.
lib_gdf = osmnx.geometries_from_place("Vermont, United States", tags={"amenity": ["library"]}) print("There are "+str(len(lib_gdf))+" libraries in Vermont, USA.")
The data are returned as a GeoPandas GeoDataFrame. This enables easy plotting and exploration of the spatial data. You can use the head
method to view the top few rows, and the plot
method to plot the geometries. If you're familiar with the shape of Vermont you can roughly see it in the plot.
lib_gdf.head(5)
lib_gdf.plot()
Query Earth OnDemand for Imagery
We pass the GeoDataFrame into our earth_ondemand.read_catalog
function. Because some geometries are points and others are polygons, we create a small buffer to force them all to be polygons, since the EarthAI Catalog API requires all input geometries to be the same type.
lib_gdf.geom_type.value_counts()
lib_cat = earth_ondemand.read_catalog(lib_gdf.buffer(0.0001), '2019-06-01', '2019-06-11', collections='landsat8_c2l1t1' )
You can download a companion notebook that runs through these steps from the attachment below.
Comments
0 comments
Please sign in to leave a comment.