Get startedGet started for free

Mapping California Colleges

1. Mapping a State's Colleges

Now that we have a general sense of the data we are working with, let's dive in and take a closer look at all of the colleges in one state. As an example, we'll create a subset of the IPEDS data with only colleges in Maine to plot on a leaflet map.

2. How many 4-year colleges are there in Maine?

How many four-year colleges do you think there are in Maine, a state with approximately 1-dot-3 million residents compared to California's nearly 40 million? To figure out the answer, we can filter the IPEDS data to the observations that have a state value of ME, which is the common abbreviation used for Maine in the United States. This gives us a tibble with 21 rows, telling us that there are 21 four-year colleges in Maine. Perhaps, a more interesting question is how are these 21 colleges distributed throughout the state? Let’s make a map to find out.

3. Mapping a State's Colleges

When we pass our data on Maine's colleges to addMarkers, leaflet tells us that it has automatically identified the variables that represent our coordinates. Using these coordinates, leaflet creates a map that is zoomed out to Maine by default and reveals that 19 of Maine's 21 four-year colleges are in the southern half of the state. This clustering of colleges leads to some overlapping of the pin markers. You can imagine how this might look in a state with more colleges, like California.

4. Mapping a State's Colleges

When we make maps with markers that are clustered together, the pin markers rendered by addMarkers() can overlap and obscure our data. One alternative is to use the addCircleMarkers() function. Why are the pin markers still showing up on our map? Remember, each set of markers are their own layer, so adding a new set will not replace the existing ones.

5. Mapping a State's Colleges

Often it is desirable to add different types of markers to a map to identify different types of data, however this is not one of those times, so we need to clear the pins prior to adding the circle markers. This approach renders a map with blue circle markers with a radius of 3 pixels representing the locations of Maine's 21 four-year colleges.

6. Mapping a State's Colleges

We can customize several aspects of our circle markers. For example, we can control the radius and the color of the circles. We can also retain our pop-ups when using circle markers.

7. Let's practice!

Now it's your turn to apply what we've learned about Maine to create a map of the nearly 300 colleges in California.