Finding polygon overlays of point data
We already have all the data we need to identify the parent state of each airport. The dt
dataset includes the geo-coordinates of the locations, and we managed to render the states as polygons with the map
function. Actually, this latter function can return the underlying dataset without rendering a plot:
> str(map_data <- map('state', plot = FALSE, fill = TRUE)) List of 4 $ x : num [1:15599] -87.5 -87.5 -87.5 -87.5 -87.6 ... $ y : num [1:15599] 30.4 30.4 30.4 30.3 30.3 ... $ range: num [1:4] -124.7 -67 25.1 49.4 $ names: chr [1:63] "alabama" "arizona" "arkansas" "california" ... - attr(*, "class")= chr "map"
So we have around 16,000 points describing the boundaries of the US states, but this map data ...
Get Mastering Data Analysis with R now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.