-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f695e1
commit 01df2c4
Showing
1 changed file
with
18 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
get_dist_shore <- function(spatialgrid){ | ||
if(!any(check_raster(spatialgrid) & check_sf(spatialgrid))) stop("spatialgrid must be in raster or sf format") | ||
|
||
#get high res land polygons from Natural Earth | ||
ne_data_filename <- "ne_land_data.zip" | ||
|
||
if(!file.exists(file.path(tempdir(), "ne_10m_land.shp"))){ | ||
utils::download.file(url = "https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/physical/ne_10m_land.zip", destfile = file.path(tempdir(), ne_data_filename), mode = "wb", quiet = TRUE) | ||
utils::unzip(file.path(tempdir(), ne_data_filename), exdir = tempdir()) | ||
} | ||
|
||
ne_data <- sf::read_sf(file.path(tempdir(), "ne_10m_land.shp")) %>% | ||
sf::st_geometry() %>% | ||
sf::st_combine() %>% | ||
sf::st_sf() %>% | ||
sf::st_make_valid() %>% | ||
terra::vect() | ||
} |