LoslegenKostenlos loslegen

Projecting to Web Mercator for using web tiles

In the first chapter, we did an exercise on plotting the restaurant locations in Paris and adding a background map to it using the contextily package.

Currently, contextily assumes that your data is in the Web Mercator projection, the system used by most web tile services. And in that first exercise, we provided the data in the appropriate CRS so you didn't need to care about this aspect.

However, typically, your data will not come in Web Mercator (EPSG:3857) and you will have to align them with web tiles on your own.

GeoPandas, matplotlib and contextily are already imported.

Diese Übung ist Teil des Kurses

Working with Geospatial Data in Python

Kurs anzeigen

Anleitung zur Übung

  • Convert the restaurants dataset to the Web Mercator projection (EPSG:3857). Call the result restaurants_webmercator.
  • Make a plot of this projected dataset (specify the marker size to be 1) and add a background map using contextily.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# Convert to the Web Mercator projection
restaurants_webmercator = restaurants.____

# Plot the restaurants with a background map
ax = ____
contextily.____
plt.show()
Code bearbeiten und ausführen