-
-
Save nemochina2008/35c4753668eb309bfc42e97eeea204f1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(USAboundaries) | |
library(sf) | |
library(dplyr) | |
library(elevatr) | |
library(raster) | |
# Get map of lower 48 states | |
usa_l48 <- us_boundaries() %>% | |
filter(state_abbr != "HI" & | |
state_abbr != "AK" & | |
state_abbr != "PR") | |
# Get DEM. Zoom level 4 returns dem of ~ 3.8km resolution for whole of lower 48 | |
usa_l48_dem <- get_elev_raster(as(usa_l48, "Spatial"), src="aws", z = 4, clip = "location") | |
# Project to albers/meters | |
usgs_albers <- "+proj=aea +lat_1=29.5 +lat_2=45.5 +lat_0=37.5 +lon_0=-96 +x_0=0 +y_0=0 +ellps=GRS80 +datum=NAD83 +units=m +no_defs" | |
usa_l48_alb <- usa_l48 %>% | |
st_transform(crs = usgs_albers) | |
usa_l48_dem_alb <- projectRaster(usa_l48_dem, crs = usgs_albers) | |
# Plot it | |
plot(usa_l48_dem_alb) | |
plot(st_geometry(usa_l48_alb), fill = F, add = T) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment