LoslegenKostenlos loslegen

Plotting points over polygons - part 2

We have loaded the usual libraries as pd, plt, and gpd, the chickens dataset as chickens, and the service districts as service_district. Plot the service districts and chicken permits together to see what story your visualization tells.

Diese Übung ist Teil des Kurses

Visualizing Geospatial Data in Python

Kurs anzeigen

Anleitung zur Übung

  • Start by plotting the GeoDataFrame with the service districts. Use the name column for your legend color.
  • Next plot latitude and longitude from the chicken data to create a scatterplot. Specify 'black' for the marker color and give them a 'white' outline.
  • Give the plot a title: 'Nashville Chicken Permits' and label the x-axis as 'longitude' and the y-axis as 'latitude'.
  • Add grid lines and show your plot.

Interaktive Übung

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

# Plot the service district shapefile
service_district.plot(column=____, legend=True)

# Add the chicken locations
plt.scatter(x=____, y=____, c=____, edgecolor = 'white')


# Add labels and title
plt.____('Nashville Chicken Permits')
plt.xlabel(____)
plt.ylabel(____)

# Add grid lines and show the plot
plt.____()
plt.____()
Code bearbeiten und ausführen