opendatacube / odc-geo

GeoBox and geometry utilities extracted from datacube-core
https://odc-geo.readthedocs.io/en/latest/
Apache License 2.0
83 stars 15 forks source link

add_to with name is not passing the name in to Folium #108

Closed alexgleith closed 1 year ago

alexgleith commented 1 year ago

I'm adding a couple of xarray variables to a folium map, and it works fantastically but I can't get it to name them neatly.

Here's my code:

import folium
import odc.geo.xr

m = folium.Map(control_scale=True, tiles=None)

data.vv.odc.add_to(m, opacity=0.7, name="vv")
data.vh.odc.add_to(m, opacity=0.7, name="vh")

# Zoom map
m.fit_bounds(data.odc.map_bounds())

tile = folium.TileLayer(
    tiles = 'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
    attr = 'Esri',
    name = 'Esri Satellite',
    overlay = False,
    control = True
).add_to(m)
folium.TileLayer('openstreetmap').add_to(m)

folium.LayerControl().add_to(m)
display(m)

I have the following software versions:

And here's how the layers display:

image

Kirill888 commented 1 year ago

@alexgleith this is a dupe of #102 and has been fixed in #103, we need to make a release with that fix.

Kirill888 commented 1 year ago

can you please try with code in develop branch and see if that issue is fixed for your example?

alexgleith commented 1 year ago

Ok, tested.

Installed from git pip3 install --upgrade git+https://github.com/opendatacube/odc-geo.git@develop

Results in: pip freeze | grep odc-geo

odc-geo @ git+https://github.com/opendatacube/odc-geo.git@53535c8dfd58dd10e7e93c676055a57fb3ec95cd

Now restarting a notebook kernel and re-running gives me a nicely labelled layer.

Thanks Kirill!

image

Kirill888 commented 1 year ago

@alexgleith thanks for testing, this is now released as odc-geo==0.4.1 on both pypi and conda-forge