LoslegenKostenlos loslegen

Art distances from neighborhood center

Now that you have the center point and the art locations in the units we need to calculate distances in meters, it's time to perform that step.

Diese Übung ist Teil des Kurses

Visualizing Geospatial Data in Python

Kurs anzeigen

Anleitung zur Übung

  • Import the package to help with pretty printing.
  • Create a dictionary, art_distances by iterating through art_dist_meters, using title as the key and the distance() from center as the value. Pass center as the other argument to GeoSeries.distance().
  • Pretty print art_distances using the pprint method of pprint.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

# Import package for pretty printing
import ____

# Build a dictionary of titles and distances for Urban Residents art
art_distances = {}
for row in ____.iterrows():
    vals = row[1]
    key = vals['title']
    ctr = vals[____]
    art_distances[key] = vals['geometry'].distance(____)

# Pretty print the art_distances
____.____(art_distances)
Code bearbeiten und ausführen