overwrite geopackage when combining data
This commit is contained in:
parent
7eddee51b4
commit
2ddad90d52
@ -2,6 +2,7 @@
|
||||
library(nhdplusTools)
|
||||
library(sf)
|
||||
|
||||
# set data dir
|
||||
nhdplusTools_data_dir(dir = "data")
|
||||
|
||||
# load extent of map
|
||||
@ -28,9 +29,18 @@ extent <- list(longitude_max = max(extent$longitude),
|
||||
extent_huc <- get_huc(AOI = extent_poly, buffer = 0, type = "huc04")
|
||||
|
||||
# download data
|
||||
download_nhdplushr("data", extent_huc$huc4, download_files = TRUE)
|
||||
download_nhdplushr(nhdplusTools_data_dir(), extent_huc$huc4, download_files = TRUE)
|
||||
|
||||
# get vaa
|
||||
get_vaa()
|
||||
|
||||
# combine data into geopackage
|
||||
data <- get_nhdplushr(hr_dir = "data",
|
||||
out_gpkg = "data/data.gpkg",
|
||||
layers = NULL)
|
||||
layers <- c("NHDArea",
|
||||
"NHDFlowline",
|
||||
"NHDWaterbody",
|
||||
"NHDPlusLandSea")
|
||||
|
||||
data <- get_nhdplushr(hr_dir = nhdplusTools_data_dir(),
|
||||
out_gpkg = paste0(nhdplusTools_data_dir(),"/data.gpkg"),
|
||||
layers = layers,
|
||||
overwrite = TRUE)
|
||||
|
@ -1,16 +1,9 @@
|
||||
# load libraries
|
||||
library(sf)
|
||||
|
||||
# load data
|
||||
|
||||
|
||||
layers <- c("NHDArea",
|
||||
"NHDFlowline",
|
||||
"NHDWaterbody",
|
||||
"NHDPlusLandSea")
|
||||
|
||||
# load and crop data
|
||||
data <- list(NULL)
|
||||
sf_use_s2(FALSE)
|
||||
for (layer in layers){
|
||||
data[[layer]] <- st_crop(st_read("data/data.gpkg", layer = layer), y = extent_bbox)
|
||||
data[[layer]] <- st_crop(st_read(paste0(nhdplusTools_data_dir(),"/data.gpkg"), layer = layer), y = extent_bbox)
|
||||
}
|
||||
|
@ -1,3 +1,3 @@
|
||||
latitude,longitude
|
||||
43.63839,-89.97779
|
||||
42.52677,-88.52104
|
||||
47.33402,-93.10419
|
||||
42.43754,-86.832
|
||||
|
|
Loading…
x
Reference in New Issue
Block a user