geanders / stormwindmodel

Model Hurricane Wind Speeds
25 stars 11 forks source link

Change mapping functions to use simple features (`sf` package) #47

Open geanders opened 2 years ago

geanders commented 2 years ago

Now that the sf package is well-developed, I think our mapping functions would work better in that system. One idea might be a function that creates an sf object from the grid winds output. This would input a dataset with the latitude and longitude of the grid points (could be an sf object with the gridpoint id as the first column and then the geometry column with the latitude and longitude), then merge in the wind speed and surface wind direction data by gridpoint id so that those pieces of data could easily be mapped.

We could also create a function that takes the storm track info and creates an sf object, so that could be added as a layer to the maps.

There's an excellent book on the sf package and related functions here: https://geocompr.robinlovelace.net/

geanders commented 2 years ago

For the case of counties, it would also be interesting to write a function that can merge with the county polygons, so that we can make chloropleth maps. This would probably use tigris to read in the county boundaries (it would only work in the US in that case), then merge with the grid wind output using the grid point IDs (FIPS codes). Then this sf object could be plotted or added as a layer to another map pretty easily.

geanders commented 2 years ago

Another source with great info on sf: https://r-spatial.org/r/2018/10/25/ggplot2-sf.html