Aan de slagGa gratis aan de slag

Adding markers for the public art

Now that you have added the polygon for the Urban Residents neighborhood to your folium street map, it's time to add the locations of the art within the neighborhood. You can do that by creating folium markers. Each marker needs a location assigned. Use iterrows() to loop through the data to grab the values you need.

Deze oefening maakt deel uit van de cursus

Visualizing Geospatial Data in Python

Cursus bekijken

Oefeninstructies

  • First take a look at the tuple returned by iterrows() by printing the first and second values.
  • Assign the second value of the iterrows() tuple to row_values. Create a location formatted for folium, use it to build a marker, and add it to the downtown_map.
  • Display the map.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Iterate through the urban_art and print each part of tuple returned
for row in urban_art.iterrows():
  print('first part: ', row[____])
  print('second part: ', row[____])

# Create a location and marker with each iteration for the downtown_map
for row in urban_art.iterrows():
    row_values = row[1] 
    location = [row_values[____], row_values[____]]
    marker = folium.Marker(location = ____)
    marker.____(downtown_map)

# Display the map
display(____)
Code bewerken en uitvoeren