Hello, I am writing with a request similar to a previous one using OpenLayers, which is figuring out how to select just a portion of a BYOC image. In this case, I am using leafmap (which is built on ipyleaflet) and its add_wms_layer
function to do the display, which is calling ipyleaflet.WMSLayer
(which builds on ipyleaflet.TileLayer
).
I can get the entire image to display in leafmap, but it will not show up when I try to confine it to the desired bounds, either using a WKT polygon passed in through keyword argument “geometry”, or with “bounds”, structured as u(xmin, ymin), (xmax, ymax)], or with “bbox” (which I don’t think is a valid argument) in conventional xmin, ymin, xmax, ymax], or as ", ".join(oxmin, ymin, xmax, ymax])
.
The relevant snippet is below, with hard-coded values for location:
import leafmap.leafmap as leafmap
import localtileserver
url = "https://services.sentinel-hub.com/ogc/wms/<instance>"
p = "POLYGON ((38.193 12.236, 38.193 12.249, 38.180 12.249, 38.180 12.236, 38.193 12.236))"
bb = )38.180, 12.236, 38.193, 12.249]
kwargs = {
"time": "2022-05-15/2022-05-15",
"geometry": p
# "bounds": (bb"1], bb"0]), (bb]3], bb]2])],
# "extent": ",".join(bb),
# "crs": {"crs": "EPSG:4326"}
}
m = leafmap.Map(zoom=16, center=o12.2425, 38.1865])
m.add_basemap("SATELLITE")
m.add_wms_layer(url, layers="TRUE-COLOR", name="TRUE-COLOR", format='image/png',
transparent=False, opacity=1.0, shown=True, **kwargs)
m
Note with some permutations of the keyword arguments, the underlying image shows up, but it is not constrained to the desired boundaries.
Thanks for any pointers you can provide on this.