Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/geocompr/py
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeldorman committed Oct 28, 2023
2 parents 3098715 + 522bb6e commit 835a5ef
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions 08-mapping.qmd
Expand Up @@ -391,22 +391,16 @@ nzw = nz[nz['Name'] == 'Nelson'].to_crs(epsg=3857)
```

To add a basemap, we use the `contextily.add_basemap` function, similarly to the way we added multiple layers (@sec-plot-static-layers).
The default basemap is "Stamen Terrain".
<!-- jn: correct me if I am wrong, but the default basemap does not seem to be Stamen Terrain... Please check it, and update the text and code -->
The default basemap is "OpenStreetMap".
You can specify a different basemap using the `source` parameter, with one of the values in `cx.providers` (@fig-basemap).

```{python}
#| label: fig-basemap
#| fig-cap: Adding a basemap to a static map, using `contextily`
#| layout-ncol: 3
#| fig-subcap:
#| - "'Stamen Terrain' basemap (the default)"
#| - "'OpenStreetMap' basemap"
#| - "'CartoDB Positron' basemap"
# Stamen Terrain
fig, ax = plt.subplots(figsize=(7, 7))
ax = nzw.plot(color='none', ax=ax)
cx.add_basemap(ax);
# OpenStreetMap
fig, ax = plt.subplots(figsize=(7, 7))
ax = nzw.plot(color='none', ax=ax)
Expand Down Expand Up @@ -647,14 +641,9 @@ The basemap in `.explore` can be specified using the `tiles` argument.
Several popular built-in basemaps can be specified using a string:

- `'OpenStreetMap'`
- `'Stamen Terrain'`
- `'Stamen Toner'`
- `'Stamen Watercolor'`
- `'CartoDB positron'`
- `'CartoDB dark_matter'`

<!-- jn: please recheck the above list... there was some changes with Stamen maps recently, and I am not sure if the list is still correct... -->

Other basemaps are available through the **xyzservices** package, which needs to be installed (see `xyzservices.providers` for a list), or using a custom tile server URL.
For example, the following expression displays the `'CartoDB positron'` tiles in an `.explore` map (@fig-explore-basemaps).

Expand Down

0 comments on commit 835a5ef

Please sign in to comment.