Is it possible to access the underlying image from hv.element.tiles.EsriImagery()
? I would like to access the tile image and run an object detection model on it.
When I try accessing the .data
property, I see the template url https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{Z}/{Y}/{X}.jpg
, however I am interested in accessing the image of the specific tile that is being displayed and then using it for additional processing.
Yes, it's possible, and we have an example like just that! It's not yet fully published, but the source code is reachable at https://github.com/pyviz-topics/examples/pull/193 . The relevant function is in GeoViews (geoviews/util.py):
def get_tile_rgb(tile_source, bbox, zoom_level, bbox_crs=ccrs.PlateCarree()):
"""
Returns an RGB element given a tile_source, bounding box and zoom level.
Parameters
----------
tile_source: WMTS element or string URL
The tile source to download the tiles from.
bbox: tuple
A four tuple specifying the (left, bottom, right, top) corners of the
domain to download the tiles for.
zoom_level: int
The zoom level at which to download the tiles
bbox_crs: ccrs.CRs
cartopy CRS defining the coordinate system of the supplied bbox
Returns
-------
RGB element containing the tile data in the specified bbox
"""