Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor basemap module on top of xyzservices #854

Closed
martinfleis opened this issue Aug 3, 2021 · 8 comments · Fixed by #857
Closed

Refactor basemap module on top of xyzservices #854

martinfleis opened this issue Aug 3, 2021 · 8 comments · Fixed by #857

Comments

@martinfleis
Copy link

Hi all,

I'd like to start a focused discussion as a follow-up of geopandas/contextily#153 and #741.

We have built a new package called xyzservices to serve as a unified place for XYZ tile management. The idea behind this is that other packages will depend on that instead of having their own system.

In the case of ipyleaflet, that means refactoring basemaps module in a way that does not contain any hard-coded data and only wraps what ``xyzservices` provides.

From a quick look, it could take the form of replacing your Bunch with xyzservices.providers Bunch and of small changes in

def basemap_to_tiles(basemap, day='yesterday', **kwargs):
to match the xyzservices API (to get the proper form of URL (xref geopandas/xyzservices/pull/60) and attribution).

xyzservices itself does not have any dependencies which makes it a non-problematic dependency.

Some of you also mentioned you wanted the JSON stored in share. That also comes with xyzservices if you have a use case for that.

I am happy to do any changes in xyzservices needed to make it as useful for you as possible if that allows centralising maintenance of providers in one place.

What are your thoughts on this?

@giswqs
Copy link
Contributor

giswqs commented Aug 3, 2021

Great idea for having a unified place for XYZ tiles rather than managing them in each individual package. I look forward to using it in geemap and leafmap. Would xyzservices consider adding wmsservices support? Or should it be another independent package?

A lot of WMS services can be found at https://apps.nationalmap.gov/services

@martinfleis
Copy link
Author

Would xyzservices consider adding wmsservices support? Or should it be another independent package?

-> geopandas/xyzservices#49 (comment) tldr: Yes, it sounds like a good addition.

@sackh
Copy link
Contributor

sackh commented Aug 6, 2021

@martinRenou, @davidbrochart If you guys agree I would like to work on this.
let me know your thoughts.

@davidbrochart
Copy link
Member

I don't know if @giswqs is already on it?
I like that people are fighting to contribute to ipyleaflet 😄

@giswqs
Copy link
Contributor

giswqs commented Aug 6, 2021

I have not started yet. Maybe @sackh can refactor and basemap module first. Once his pull request is merged, I can work on the toolbar and basemap GUI.

@sackh
Copy link
Contributor

sackh commented Aug 8, 2021

I have the below questions:

  1. There are NASAGIBS basemaps URLs where %s is replaced by date, how this should be handled ? if we remove this replacement logic then def basemap_to_tiles(basemap, day='yesterday', **kwargs): day parameter is not required in this function. and it will be a breaking change.
  2. currently HERE basemaps are handled separately here shall we remove this ? again a breaking change.

@martinfleis
Copy link
Author

There are NASAGIBS basemaps URLs where %s is replaced by date, how this should be handled ? if we remove this replacement logic then def basemap_to_tiles(basemap, day='yesterday', **kwargs): day parameter is not required in this function. and it will be a breaking change.

You can map the same functionality onto xyz.NASAGIBS objects.

Take xyz.NASAGIBS.ModisTerraTrueColorCR as an example. It has the following URL stored:

{'url': 'https://map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{max_zoom}/{z}/{y}/{x}.{format}',
'html_attribution': 'Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (<a href="https://earthdata.nasa.gov">ESDIS</a>) with funding provided by NASA/HQ.',
'attribution': 'Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS) with funding provided by NASA/HQ.',
'bounds': [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]], 
'min_zoom': 1, 
'max_zoom': 9, 
'format': 'jpg', 
'time': '', 
'tilematrixset': 'GoogleMapsCompatible_Level', 
'variant': 'MODIS_Terra_CorrectedReflectance_TrueColor', 
'name': 'NASAGIBS.ModisTerraTrueColorCR'}

The object itself has an empty attribute time, so you can create time-based URL as xyz.NASAGIBS.ModisTerraTrueColorCR.build_url(time='2021-08-07') which fills the correct place in the URL.

So instead of url = url % day you will pass day as time to build_url. That ensures that there's no breaking change (or no visible at all). Would that work?

currently HERE basemaps are handled separately here shall we remove this ? again a breaking change.

I guess you can map those onto xyz objects as well to make it non-breaking.

@sackh
Copy link
Contributor

sackh commented Aug 9, 2021

Thanks, @martinfleis

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants