I’m jumping into maps a bit and seeing that a lot of the templates require FIPS codes to, for example, make a county-level choropleth. I’m wondering how I could go from long/lat coordinates to FIPS codes in JS. I’m coming from R and there’s an example I found that can take coordinates and convert to GEOID’s (fips). Is there a way to do this kind of thing all in Observable?
General Background: new to maps and thought the choropleth was an easier starting point than projections. Got other pointers? School me, please!
I’ve made quite a few choropleths and never really had the need to send lon/lat coords to FIPS code. The whole point behind FIPS codes is to ensure that you’ve got some standard way to associate data with geographic entities.
Here’s a pretty simple choropleth that I built recently as an ad for a class I’ll be teaching next semester. There are two FileAttachments:
contiguous_states_tigerline.json, which is a topojson describing the geography and
pop.csv, which is tabular data with populations.
Both files refer to FIPS code so it’s easy to attach the data.
Very nice! I guess I’m curious about using some process when I have data as coordinates rather than FIPS. Do you have a go-to example/approach for plotting coordinate data?
Sure - You’ve probably got a projection for the map so you just apply that to the points in your data. Here’s an example where I assume that you want to plot a list of cities as points on a map of the US and the coordinates of those points are stored as lon/lat data. The process would be similar, though, if you want to any other type of object.
The R example to which you linked seems to use a kind of reverse geocoding, where you have a point and you want to find the shape (.e.g., county, state, tract) in which that point falls. This process can end up with a choropleth, though it’s more of a data management step than a visualization one.
In my work, I often have a bunch points which represent the locations of healthcare providers, so I reverse them to individual counties or census tracts using a shapefile. At this point, I have a FIPS code as a result of the reversing process. I aggregate providers with the same FIPS code and divide them by the general population of the containing shape/geography to derive a rate. I then make a choropleth of the rate.
To @mcmcclur’s point, the key thing is that I need to end up with a dataset that has FIPS codes (at least with US data) in order to map those rates to colors and geographies.
Thank you both, helpful resources to check out!