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

Added webmap feature with Contextily module #48

Closed

Conversation

pandeazucar
Copy link

Added the contextily module to be used for downloading web tiles and using them for basemaps.
The feature uses the bounds of the GeoDataFrame or GeoSeries object supplied by the user, as well as a parameter for specifying the web tiles URL.
The webmap parameter should evaluate to one of the URLs in the contextily/tile_providers.py file.
For now, the feature should only work correctly for plotting in the Mercator projection, as the tiles come in EPSG:3857 (Web Mercator).

The API is:
gplt.polyplot(df, projection=gcrs.Mercator(), webmap="OSM_A")

It passed the tests but it has behaved strangely in my computer, especially the calls to the dictionary keys or variables from contextily/tile_providers.py (which the interpreter signals as a NameError for some reason). For now I have only supplied the feature code to the polyplot class. It should be trivial to add it to the other functions, as soon as I can get it working properly.

The zorder parameter in the ax.imshow() call is because the tile image should be used in the background as a basemap.

This pull request is mainly to show what I have done so far and the basic idea behind the code.

Please, I will welcome any suggestions about the code.

@ResidentMario
Copy link
Owner

Toying with this on my local machine now.

In terms of API, the parameterization looks good.

We should have simply gplt.polyplot(df, webmap="OSM_A") work as well, raising a warning telling the user that specifying a webmap parameter forces the Mercator projection.

Additionally we will need to add a component raising an error when the user specifies both a webmap and a non-Mercator projection.

Since this is going to apply to all of the plot types, later on we will want to consolidate all of the new methodology in a new method or handful of methods. Not yet, but an FYI for later.

You state that "The feature uses the bounds of the GeoDataFrame or GeoSeries object supplied by the user". What will happen if the user uses a pattern where they reuse the axis? E.g. over-plotting a pointplot (potentially one with radically different boundaries) over a polyplot. We should figure out what we can do in this case.

Now, with the output. I've cloned this feature and specified the following minimal example:

import pandas as pd
from quilt.data.ResidentMario import geoplot_data
import geopandas as gpd
%matplotlib inline

boroughs = gpd.read_file(geoplot_data.nyc_boroughs())

import geoplot as gplt
import geoplot.crs as gcrs

gplt.polyplot(boroughs, projection=gcrs.Mercator(), webmap="OSM_A")

However, I'm not getting the intended output. =( Does this example work for you?

@ResidentMario
Copy link
Owner

Closing as stale. This feature is on the near-term roadmap.

@ResidentMario ResidentMario mentioned this pull request Jul 5, 2019
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 this pull request may close these issues.

None yet

2 participants