Since we're all at home panic-refreshing Twitter, let's use this time to learn a new geospatial concept! Today's lesson: converting points to polygons. (If you've ever wondered why cartographers hate on zipcode data, read on!)
Here’s our data! Let’s say it’s addresses where cute dogs live. You want to create a boundary (a polygon) that includes all the cute dogs.
Here’s one way to do it: literally draw an area that includes all the points.
Sweet we did it! But what does this polygon tell us about the underlying point data? Not much. That polygon can be massive and still contain all those points.
Imagine another use case: every point is a nest from a particular type of bird. Our goal is to figure out that bird’s endemic region based on this data. In that case, we probably want our polygon to fit the point data more closely.
There are two tools/concepts to cover here: concave hull and convex hull. Here’s what they both look like: concave hull in green, convex hull in orange.
“Concave hull” is the smallest area that contains all the points. Think of this like shrinkwrap, wrapping all of these points. While a concave hull contains the smallest area, it also creates the longest boundary.
“Convex hull” is the simplest polygon that contains all of the points. Think of this like a rubber band wrapping around all the points.
What does this have to do with zip codes? Boy am I glad you asked!
Welcome to Anytown, USA. The purple lines are roads and the black points are addresses. We are the US Postal Service.
Anytown has two zip codes, A and B.
So if my job is to deliver to all homes in zip code A, what is my delivery area? It depends. Let’s try it with a convex hull:
And a concave hull:
Okay cool this makes sense, every address is contained. But what if someone builds a new house? Here’s their new (pink!) driveway and their new house.
With a convex hull around zip code B, the new house clearly falls into that zip code. But I gave it zip code A. Why?
Because as a mail delivery person, I need to stay on the road, on my route. My buddy in zip code B isn’t going to roll all the way down to my area, up and around to get to the new house because it happens to be in their zip code area. No, it’s on my route, it gets zip code A.
So a true zip code area is a set of points (addresses), connected to each other by a set of lines (roads), and many areas that don’t have addresses and aren’t included at all (blue circles).
THIS IS WHY ZIP CODE POLYGONS ARE UNRELIABLE! There are many methods to use when creating a polygon out of points, and it fully depends on the use case. And guess what y’all, the USPS use case doesn’t really apply to most other uses.
If you want to take the US & break it up into chunks to visualize or do analysis, may I suggest:

- census tracts, which each have roughly the same amount of people (2,500-8,000)
- hexagons, which contain the same geographic area
- political boundaries, if your use case warrants
Thank you for tuning into this Twitter-torial! I’ll be here forever probably doing this again tomorrow because it was a nice little break from freaking out about the end of the world. ✌️💕🗺
You can follow @lyzidiamond.
Tip: mention @twtextapp on a Twitter thread with the keyword “unroll” to get a link to it.

Latest Threads Unrolled: