importMap.Rd
Import a raster for a specific region from a multisource environment, such as the outputs of the getMap function.
importMap(
region,
polys,
tile_id = "TILEID",
z_fix = NULL,
neighbor_distance = 5,
FUN = NULL,
mask = FALSE,
vals = "location",
filt = 0,
z_min = NULL,
dir = tempdir(),
...
)
A SpatRaster, Raster*, SpatVector, Spatial* or character string representing the area of interest
A polygon of class SpatVector representing the partitioning grid
for the maximum possible area, in the same format as the output of the
makeGrid
function.
A character string representing the name of the column in the
polys
polygon pontaining the unique Tile IDs. Default is
tile_id = 'TILEID'
A SpatRaster or Raster* object with the desired output projection,
resolution, and origin. Required if tiles
is of classes SpatVector,
Spatial*, or character, unless res
is provided.
An integer representing the number of cells that
tiles are buffered. In other words, to ensure that there are no gaps between tiles,
neighboring tiles within neighborhood_distance
cells are also considered as
potential sources. Default is 5 cells.
Function to deal with overlapping values for overlapping tiles.
Default is NA
, which uses merge
. To use
mosaic
, provide a compatible function
If FALSE
(the default), the output map will contain all cells
falling within the extent of region
. If TRUE
, places with NA
(if region
is SpatRaster or Raster*) or no coverage (if region
is
SpatVector or Spatial*) will be assigned a value of NA.
A character string or a Raster* object. Required only if the
z
parameter is a polygon NOT the output of the
makeGrid
function as the default is
the character string 'location'
. If not, the vals
parameter should be
set to the column name containing the URL or file path to the DEM for that
sector.
Numeric. Size of moving window to apply a low-pass filter. Default
is filt = 0
. Ignored unless the tiles need to be generated from
the raw source files.
The minimum allowable elevation. Useful if DEM source includes
ocean bathymetry as does the SRTM data from AWS. Default is z_min = NULL
,
but set to 0
for SRTM data. Ignored unless the tiles need to be generated from
the raw source files.
A filepath to the directory being used as the workspace. Default
is tempdir()
, but unless the analyses will only be performed a few times
it is highly recommended to define a permanent workspace.
Additional agruments to pass to fix_z
# Generate a DEM, export it
n <- 5
dem <- expand.grid(list(x = 1:(n * 100),
y = 1:(n * 100))) / 100
dem <- as.data.table(dem)
dem[, z := 250 * exp(-(x - n/2)^2) +
250 * exp(-(y - n/2)^2)]
#> x y z
#> 1: 0.01 0.01 1.0146139
#> 2: 0.02 0.01 1.0404641
#> 3: 0.03 0.01 1.0675194
#> 4: 0.04 0.01 1.0958300
#> 5: 0.05 0.01 1.1254477
#> ---
#> 249996: 4.96 5.00 1.0711366
#> 249997: 4.97 5.00 1.0428260
#> 249998: 4.98 5.00 1.0157707
#> 249999: 4.99 5.00 0.9899205
#> 250000: 5.00 5.00 0.9652271
dem <- rast(dem)
ext(dem) <- c(10000, 20000, 30000, 40000)
crs(dem) <- "+proj=lcc +lat_1=48 +lat_2=33 +lon_0=-100 +datum=WGS84"
dir <- tempdir()
writeRaster(dem, paste0(dir,"/DEM.tif"),overwrite=TRUE)
# Import raster, get the grid
dem <- rast(paste0(dir,"/DEM.tif"))
grid <- makeGrid(dem = dem, nx = n, ny = n, sources = TRUE)
# Import the map for the center tile resampled to a different resolution
dem2 <- importMap('SECTOR_13', grid, res = 20)