Added webmap feature with Contextily module #48
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.