ComenzarEmpieza gratis

Proportional Symbol Map of Households w/ Internet

To map a raw count variable, you can use a proportional symbol map to create markers of sizes that are proportional to the data value being mapped. In this exercise you will find the centroid of each state, create a basemap of states, and place a circle at each centroid that is sized by the number of households with internet access.

The area of each marker should be proportional to the data value. Since marker sizes are provided as a diameter, you must take the square root of the column value. Marker sizes may look too big or too small. In this exercise, you will divide the marker size by 5--this is an aesthetic judgment call.

geopandas is imported using the usual alias, and the sqrt function has been imported from numpy.

The geo_state GeoDataFrame has been loaded.

Este ejercicio forma parte del curso

Analyzing US Census Data in Python

Ver curso

Instrucciones del ejercicio

  • Call the centroid attribute on geo_state_pt and assign the result to the geometry column
  • Create a basemap of state borders by calling the plot method on geo_state; set the color to "tan" and the edgecolor to "black"
  • Create variable ms (to be passed to the markersize parameter) to the square root of the value of the geo_state_pt["internet"] column divided by 5

Ejercicio interactivo práctico

Prueba este ejercicio y completa el código de muestra.

# Create point GeoDataFrame at centroid of states
geo_state_pt = geo_state.copy()
geo_state_pt["geometry"] = ____

# Set basemap and create variable for markersize
basemap = ____
ms = ____

# Plot proportional symbols on top of basemap
geo_state_pt.plot(ax = basemap, markersize = ms, color = "lightgray", edgecolor = "darkgray")
plt.show()
Editar y ejecutar código