| Title: | Defines a meta class of geographical objects, the 'map' class, and associated tools |
|---|---|
| Description: | The 'map' class is a collection of geospatial objects (e.g., from the 'sp', 'raster', 'sf', and 'terra' packages), with a number of metadata additions to enable powerful methods, e.g., for 'leaflet', reproducible GIS etc. |
| Authors: | Eliot J B McIntire [aut] (ORCID: <https://orcid.org/0000-0002-6914-8316>), Alex M Chubaty [aut, cre] (ORCID: <https://orcid.org/0000-0001-7146-8135>), His Majesty the King in Right of Canada, as represented by the Minister of Natural Resources Canada [cph] |
| Maintainer: | Alex M Chubaty <[email protected]> |
| License: | GPL-3 |
| Version: | 1.1.2.9002 |
| Built: | 2026-06-02 23:46:05 UTC |
| Source: | https://github.com/PredictiveEcology/map |
.rasterToMemory.rasterToMemory
.rasterToMemory(x, ...) ## S3 method for class 'Raster' .rasterToMemory(x, ...) ## S3 method for class 'SpatRaster' .rasterToMemory(x, ...).rasterToMemory(x, ...) ## S3 method for class 'Raster' .rasterToMemory(x, ...) ## S3 method for class 'SpatRaster' .rasterToMemory(x, ...)
x |
A |
... |
Additional arguments passed to raster read function |
shinyLabel column (attribute) to spatial vectorsAdd shinyLabel column (attribute) to spatial vectors
addColumnNameForLabels(x, columnNameForLabels, ...) ## Default S3 method: addColumnNameForLabels(x, columnNameForLabels, ...) ## S3 method for class 'list' addColumnNameForLabels(x, columnNameForLabels, ...) ## S3 method for class 'sf' addColumnNameForLabels(x, columnNameForLabels, ...) ## S3 method for class 'SpatialPolygonsDataFrame' addColumnNameForLabels(x, columnNameForLabels, ...) ## S3 method for class 'SpatVector' addColumnNameForLabels(x, columnNameForLabels, ...)addColumnNameForLabels(x, columnNameForLabels, ...) ## Default S3 method: addColumnNameForLabels(x, columnNameForLabels, ...) ## S3 method for class 'list' addColumnNameForLabels(x, columnNameForLabels, ...) ## S3 method for class 'sf' addColumnNameForLabels(x, columnNameForLabels, ...) ## S3 method for class 'SpatialPolygonsDataFrame' addColumnNameForLabels(x, columnNameForLabels, ...) ## S3 method for class 'SpatVector' addColumnNameForLabels(x, columnNameForLabels, ...)
x |
a spatial vector object ( |
columnNameForLabels |
character or integer identifying an existing column (attribute)
to use as the |
... |
Additional arguments passed to other methods (not used) |
a modified object with the same class as x
Polygonize a raster and calculate the area of each polygon.
areaAndPolyValue(ras, ...) ## S3 method for class 'Raster' areaAndPolyValue(ras, ...) ## S3 method for class 'SpatRaster' areaAndPolyValue(ras, ...)areaAndPolyValue(ras, ...) ## S3 method for class 'Raster' areaAndPolyValue(ras, ...) ## S3 method for class 'SpatRaster' areaAndPolyValue(ras, ...)
ras |
A |
... |
Additional arguments (not used) |
list containing: sizeInHa, the area; and polyID, the polygon ID.
map object metadata tableBuild map object metadata table
buildMetadata( metadata, isStudyArea, isRasterToMatch, layerName, obj, columnNameForLabels, objHash, leaflet, envir, ... )buildMetadata( metadata, isStudyArea, isRasterToMatch, layerName, obj, columnNameForLabels, objHash, leaflet, envir, ... )
metadata |
metadata |
isStudyArea |
Logical indicating whether |
isRasterToMatch |
Logical indicating whether |
layerName |
Character specifying a label for this layer. |
obj |
The geospatial object being added to the |
columnNameForLabels |
Character specifying the column name to use for labels. |
objHash |
Character specifying the digest hash of the object. |
leaflet |
Logical or Character vector of path(s) to write tiles.
If |
envir |
TODO: description needed |
... |
Additional arguments. |
map
Extract the CRS of a map
## S4 method for signature 'map' crs(x, ...)## S4 method for signature 'map' crs(x, ...)
x |
Raster* or Spatial object |
... |
additional arguments. None implemented |
Other mapMethods:
mapRm(),
rasterToMatch,map-method,
rasters(),
studyArea(),
studyAreaName()
A simple wrapper around terra::rasterize().
fasterize2(emptyRaster, polygonToFasterize, field)fasterize2(emptyRaster, polygonToFasterize, field)
emptyRaster |
An empty |
polygonToFasterize |
an |
field |
character or numeric. If |
an object of the same class as emptyRaster
## using sf + raster f1 <- system.file("external/lux.shp", package = "raster") v1 <- sf::st_read(f1) r1 <- raster::raster(v1, ncols = 75, nrows = 100) raster::crs(r1) <- "epsg:4326" z1 <- fasterize2(r1, v1, "NAME_2") ## using terra f2 <- system.file("ex/lux.shp", package = "terra") v2 <- terra::vect(f2) r2 <- terra::rast(v2, ncols = 75, nrows = 100) z2 <- fasterize2(r2, v2, "NAME_2") terra::compareGeom(terra::rast(z1), z2)## using sf + raster f1 <- system.file("external/lux.shp", package = "raster") v1 <- sf::st_read(f1) r1 <- raster::raster(v1, ncols = 75, nrows = 100) raster::crs(r1) <- "epsg:4326" z1 <- fasterize2(r1, v1, "NAME_2") ## using terra f2 <- system.file("ex/lux.shp", package = "terra") v2 <- terra::vect(f2) r2 <- terra::rast(v2, ncols = 75, nrows = 100) z2 <- fasterize2(r2, v2, "NAME_2") terra::compareGeom(terra::rast(z1), z2)
Polygonize a raster
gdal_polygonizeR( x, outshape = NULL, gdalformat = "ESRI Shapefile", pypath = NULL, readpoly = TRUE, quiet = TRUE )gdal_polygonizeR( x, outshape = NULL, gdalformat = "ESRI Shapefile", pypath = NULL, readpoly = TRUE, quiet = TRUE )
x |
a |
outshape |
character giving the filepath for the output shapefile. |
gdalformat |
GDAL driver to use. See |
pypath, quiet
|
deprecated. maintained for backwards compatibility only (not used). |
readpoly |
logical indicating whether the polygons object should be returned
(this was previously using |
if readpoly = TRUE (default), a SpatVector object; otherwise, NULL.
map objExtract leaflet tile paths from a map obj
leafletTiles(map)leafletTiles(map)
map |
A |
A vector of paths indicating the relative paths. Any layers that don't have leaflet tiles will return NA.
If python with GDAL support is available, uses gdal2tiles via tiler::tile()
to create tiles for use with e.g. leaflet.
makeTiles( tilePath = getOption("map.tilePath", "tiles"), obj, overwrite = FALSE, ... ) canMakeTiles()makeTiles( tilePath = getOption("map.tilePath", "tiles"), obj, overwrite = FALSE, ... ) canMakeTiles()
tilePath |
A directory to write tiles |
obj |
A raster object with or without file-backing |
overwrite |
Logical. If |
... |
Arguments passed to |
makeTiles() is invoked for it's side-effect of creating tiles in tilePath;
canMakeTiles() returns a logical indicating the availability of python and GDAL support;
Requires python with GDAL support (see tiler::tiler_options()).
Windows users should install 'OSGeo4W' (https://trac.osgeo.org/osgeo4w/).
map classContains a common system for organizing geospatial vector and raster data, principally for use with leaflet and shiny.
metadatadata.table with columns describing metadata of objects in the map.
.xDataNamed environment of geospatial data objects (e.g., sf, Raster*, Spatial*).
Each entry may also be simply an environment, which indicates
where to find the object, i.e., via get(layerName, envir = environment).
CRSThe common CRS of all layers.
pathsA named list of file paths. The default is a list of length 2 specifying
dataPath and tilePath.
analysesA data.table or data.frame of the types of analyses to perform.
analysesDataA list of data.table or data.frame of the results of the analyses.
If isStudyArea = TRUE, then several things will be triggered:
This layer will be added to metadata with studyArea set to max(studyArea(map)) + 1.
update CRS slot to be the CRS of the study area.
mapAdd(obj, map, layerName, overwrite = getOption("map.overwrite", FALSE), ...) ## Default S3 method: mapAdd( obj = NULL, map = new("map"), layerName = NULL, overwrite = getOption("map.overwrite"), columnNameForLabels = 1, leaflet = FALSE, isStudyArea = FALSE, isRasterToMatch = FALSE, envir = NULL, useCache = getOption("reproducible.useCache", TRUE), useParallel = getOption("map.useParallel", FALSE), ... )mapAdd(obj, map, layerName, overwrite = getOption("map.overwrite", FALSE), ...) ## Default S3 method: mapAdd( obj = NULL, map = new("map"), layerName = NULL, overwrite = getOption("map.overwrite"), columnNameForLabels = 1, leaflet = FALSE, isStudyArea = FALSE, isRasterToMatch = FALSE, envir = NULL, useCache = getOption("reproducible.useCache", TRUE), useParallel = getOption("map.useParallel", FALSE), ... )
obj |
Optional spatial object, currently |
map |
Optional map object. If not provided, then one will be created.
If provided, then the present |
layerName |
Required. A label for this map layer. This can be the same as the object name. |
overwrite |
Logical. If |
... |
Additional arguments passed to:
|
columnNameForLabels |
A character string indicating which column to use for labels. This is currently only used if the object is a sp::SpatialPolygonsDataFrame. |
leaflet |
Logical or Character vector of path(s) to write tiles.
If |
isStudyArea |
Logical. If |
isRasterToMatch |
Logical indicating whether the object to be added should be considered
a |
envir |
An optional environment. If supplied, then the obj will not be placed "into" the maps slot, rather the environment label will be placed into the maps slot. |
useCache |
Logical. If |
useParallel |
Logical. If |
ex_dir <- withr::local_tempdir("example_mapAdd_") withr::local_dir(ex_dir) withr::local_options(list( map.tilePath = file.path(ex_dir, "tiles"), map.useParallel = FALSE )) StudyArea <- list(cbind( x = c(-122.98, -116.1, -99.2, -106, -122.98), y = c(59.9, 65.73, 63.58, 54.79, 59.9) )) |> sf::st_polygon() |> sf::st_sfc() |> sf::st_sf(geometry = _, ID = 1L, shinyLabel = "zone2", crs = "epsg:4326") ml <- mapAdd( StudyArea, isStudyArea = TRUE, layerName = "Small Study Area", poly = TRUE, analysisGroup2 = "Small Study Area" ) if (require("SpaDES.tools", quietly = TRUE)) { smallStudyArea <- SpaDES.tools::randomPolygon(studyArea(ml), 1e5) smallStudyArea$ID <- 1L smallStudyArea$shinyLabel <- "zone2" ml <- mapAdd( smallStudyArea, ml, isStudyArea = TRUE, filename2 = NULL, analysisGroup2 = "Smaller Study Area", poly = TRUE, layerName = "Smaller Study Area" ) ## adds a second studyArea within 1st rasTemplate <- terra::rast(terra::ext(studyArea(ml)), resolution = 0.001) tsf <- SpaDES.tools::randomPolygons(rasTemplate, numTypes = 8) * 30 vtm <- SpaDES.tools::randomPolygons(tsf, numTypes = 4) levels(vtm) <- data.frame( ID = sort(unique(vtm[])), Factor = c("black spruce", "white spruce", "aspen", "fir") ) ## need python + gdal to generate leaflet tiles doLeaflet <- canMakeTiles() ml <- mapAdd( tsf, ml, layerName = "tsf1", filename2 = "tsf1.tif", ## to postProcess ## to map object tsf = "tsf1.tif", ## to column in map@metadata analysisGroup1 = "tsf1_vtm1", ## this is the label for analysisGroup1 leaflet = doLeaflet, ## to column in map@metadata; used for visualizing in leaflet overwrite = TRUE ) ml <- mapAdd( vtm, ml, filename2 = "vtm1.grd", layerName = "vtm1", vtm = "vtm1.grd", analysisGroup1 = "tsf1_vtm1", leaflet = doLeaflet, overwrite = TRUE ) ## these map analyses are in `LandWebUtils` package, which is reverse dependency of this one # ageClasses <- c("Young", "Immature", "Mature", "Old") # ageClassCutOffs <- c(0, 40, 80, 120) ## add an analysis -- this will trigger analyses because there are already objects in the map ## This will trigger 2 analyses: ## LeadingVegTypeByAgeClass on each raster x polygon combo (only 1 currently) ## so there is 1 raster group, 2 polygon groups, 1 analyses - Total 2, 2 run now # ml <- mapAddAnalysis(ml, functionName = "LeadingVegTypeByAgeClass", # ageClasses = ageClasses, ageClassCutOffs = ageClassCutOffs) ## add an analysis -- this will trigger analyses because there are already objects in the map ## This will trigger 2 more analyses: ## largePatches on each raster x polygon combo (only 1 currently) ## so there is 1 raster group, 2 polygon groups, 2 analyses - Total 4, only 2 run now # ml <- mapAddAnalysis(ml, functionName = "LargePatches", ageClasses = ageClasses, # id = "1", labelColumn = "shinyLabel", # ageClassCutOffs = ageClassCutOffs) ## Add a second polygon, trigger # smallStudyArea2 <- randomPolygon(studyArea(ml), 1e5) # smallStudyArea2$ID <- 1L # smallStudyArea2$shinyLabel <- "zone2" ## add a new layer -- this will trigger analyses because there are already analyses in the map ## This will trigger 2 more analyses ... largePatches on each *new* raster x polygon combo ## (now there are 2) -- so there is 1 raster group, 3 polygon groups, 2 analyses - Total 6 # ml <- mapAdd(smallStudyArea2, ml, isStudyArea = FALSE, filename2 = NULL, overwrite = TRUE, # analysisGroup2 = "Smaller Study Area 2", # poly = TRUE, # layerName = "Smaller Study Area 2") # adds a second studyArea within 1st ## Add a *different* second polygon, via overwrite. This should trigger new analyses. # smallStudyArea2 <- randomPolygon(studyArea(ml), 1e5) # smallStudyArea2$ID <- 1 # smallStudyArea2$shinyLabel = "zone1" ## add a new layer -- this will trigger analyses because there are already analyses in the map ## This will trigger 2 more analyses ... largePatches on each *new* raster x polygon combo ## (now there are 2) -- so there is 1 raster group, 3 polygon groups, 2 analyses - Total 6 # ml <- mapAdd(smallStudyArea2, ml, isStudyArea = FALSE, filename2 = NULL, overwrite = TRUE, # analysisGroup2 = "Smaller Study Area 2", # poly = TRUE, # layerName = "Smaller Study Area 2") # adds a second studyArea within 1st ## Add a 2nd pair of rasters # rasTemplate <- rast(ext(studyArea(ml)), res = 0.001) # tsf2 <- randomPolygons(rasTemplate, numTypes = 8)*30 # vtm2 <- randomPolygons(tsf2, numTypes = 4) # levels(vtm2) <- data.frame( # ID = sort(unique(vtm2[])), # Factor = c("black spruce", "white spruce", "aspen", "fir") # ) # ml <- mapAdd(tsf2, ml, filename2 = "tsf2.tif", layerName = "tsf2", # tsf = "tsf2.tif", # analysisGroup1 = "tsf2_vtm2", leaflet = doLeaflet, overwrite = TRUE) # ml <- mapAdd(vtm2, ml, filename2 = "vtm2.grd", layerName = "vtm2", # vtm = "vtm2.grd", # analysisGroup1 = "tsf2_vtm2", leaflet = doLeaflet, overwrite = TRUE) ## post hoc analysis of data ## use or create a specialized function that can handle the analysesData slot # ml <- mapAddPostHocAnalysis(map = ml, functionName = "rbindlistAG", # postHocAnalysisGroups = "analysisGroup2", # postHocAnalyses = "all") } ## cleanup withr::deferred_run()ex_dir <- withr::local_tempdir("example_mapAdd_") withr::local_dir(ex_dir) withr::local_options(list( map.tilePath = file.path(ex_dir, "tiles"), map.useParallel = FALSE )) StudyArea <- list(cbind( x = c(-122.98, -116.1, -99.2, -106, -122.98), y = c(59.9, 65.73, 63.58, 54.79, 59.9) )) |> sf::st_polygon() |> sf::st_sfc() |> sf::st_sf(geometry = _, ID = 1L, shinyLabel = "zone2", crs = "epsg:4326") ml <- mapAdd( StudyArea, isStudyArea = TRUE, layerName = "Small Study Area", poly = TRUE, analysisGroup2 = "Small Study Area" ) if (require("SpaDES.tools", quietly = TRUE)) { smallStudyArea <- SpaDES.tools::randomPolygon(studyArea(ml), 1e5) smallStudyArea$ID <- 1L smallStudyArea$shinyLabel <- "zone2" ml <- mapAdd( smallStudyArea, ml, isStudyArea = TRUE, filename2 = NULL, analysisGroup2 = "Smaller Study Area", poly = TRUE, layerName = "Smaller Study Area" ) ## adds a second studyArea within 1st rasTemplate <- terra::rast(terra::ext(studyArea(ml)), resolution = 0.001) tsf <- SpaDES.tools::randomPolygons(rasTemplate, numTypes = 8) * 30 vtm <- SpaDES.tools::randomPolygons(tsf, numTypes = 4) levels(vtm) <- data.frame( ID = sort(unique(vtm[])), Factor = c("black spruce", "white spruce", "aspen", "fir") ) ## need python + gdal to generate leaflet tiles doLeaflet <- canMakeTiles() ml <- mapAdd( tsf, ml, layerName = "tsf1", filename2 = "tsf1.tif", ## to postProcess ## to map object tsf = "tsf1.tif", ## to column in map@metadata analysisGroup1 = "tsf1_vtm1", ## this is the label for analysisGroup1 leaflet = doLeaflet, ## to column in map@metadata; used for visualizing in leaflet overwrite = TRUE ) ml <- mapAdd( vtm, ml, filename2 = "vtm1.grd", layerName = "vtm1", vtm = "vtm1.grd", analysisGroup1 = "tsf1_vtm1", leaflet = doLeaflet, overwrite = TRUE ) ## these map analyses are in `LandWebUtils` package, which is reverse dependency of this one # ageClasses <- c("Young", "Immature", "Mature", "Old") # ageClassCutOffs <- c(0, 40, 80, 120) ## add an analysis -- this will trigger analyses because there are already objects in the map ## This will trigger 2 analyses: ## LeadingVegTypeByAgeClass on each raster x polygon combo (only 1 currently) ## so there is 1 raster group, 2 polygon groups, 1 analyses - Total 2, 2 run now # ml <- mapAddAnalysis(ml, functionName = "LeadingVegTypeByAgeClass", # ageClasses = ageClasses, ageClassCutOffs = ageClassCutOffs) ## add an analysis -- this will trigger analyses because there are already objects in the map ## This will trigger 2 more analyses: ## largePatches on each raster x polygon combo (only 1 currently) ## so there is 1 raster group, 2 polygon groups, 2 analyses - Total 4, only 2 run now # ml <- mapAddAnalysis(ml, functionName = "LargePatches", ageClasses = ageClasses, # id = "1", labelColumn = "shinyLabel", # ageClassCutOffs = ageClassCutOffs) ## Add a second polygon, trigger # smallStudyArea2 <- randomPolygon(studyArea(ml), 1e5) # smallStudyArea2$ID <- 1L # smallStudyArea2$shinyLabel <- "zone2" ## add a new layer -- this will trigger analyses because there are already analyses in the map ## This will trigger 2 more analyses ... largePatches on each *new* raster x polygon combo ## (now there are 2) -- so there is 1 raster group, 3 polygon groups, 2 analyses - Total 6 # ml <- mapAdd(smallStudyArea2, ml, isStudyArea = FALSE, filename2 = NULL, overwrite = TRUE, # analysisGroup2 = "Smaller Study Area 2", # poly = TRUE, # layerName = "Smaller Study Area 2") # adds a second studyArea within 1st ## Add a *different* second polygon, via overwrite. This should trigger new analyses. # smallStudyArea2 <- randomPolygon(studyArea(ml), 1e5) # smallStudyArea2$ID <- 1 # smallStudyArea2$shinyLabel = "zone1" ## add a new layer -- this will trigger analyses because there are already analyses in the map ## This will trigger 2 more analyses ... largePatches on each *new* raster x polygon combo ## (now there are 2) -- so there is 1 raster group, 3 polygon groups, 2 analyses - Total 6 # ml <- mapAdd(smallStudyArea2, ml, isStudyArea = FALSE, filename2 = NULL, overwrite = TRUE, # analysisGroup2 = "Smaller Study Area 2", # poly = TRUE, # layerName = "Smaller Study Area 2") # adds a second studyArea within 1st ## Add a 2nd pair of rasters # rasTemplate <- rast(ext(studyArea(ml)), res = 0.001) # tsf2 <- randomPolygons(rasTemplate, numTypes = 8)*30 # vtm2 <- randomPolygons(tsf2, numTypes = 4) # levels(vtm2) <- data.frame( # ID = sort(unique(vtm2[])), # Factor = c("black spruce", "white spruce", "aspen", "fir") # ) # ml <- mapAdd(tsf2, ml, filename2 = "tsf2.tif", layerName = "tsf2", # tsf = "tsf2.tif", # analysisGroup1 = "tsf2_vtm2", leaflet = doLeaflet, overwrite = TRUE) # ml <- mapAdd(vtm2, ml, filename2 = "vtm2.grd", layerName = "vtm2", # vtm = "vtm2.grd", # analysisGroup1 = "tsf2_vtm2", leaflet = doLeaflet, overwrite = TRUE) ## post hoc analysis of data ## use or create a specialized function that can handle the analysesData slot # ml <- mapAddPostHocAnalysis(map = ml, functionName = "rbindlistAG", # postHocAnalysisGroups = "analysisGroup2", # postHocAnalyses = "all") } ## cleanup withr::deferred_run()
map objectTODO: description needed
mapAddAnalysis( map, functionName, useParallel = getOption("map.useParallel", FALSE), ... )mapAddAnalysis( map, functionName, useParallel = getOption("map.useParallel", FALSE), ... )
map |
A |
functionName |
The name of the analysis function to add |
useParallel |
Logical indicating whether to use multiple threads.
Defaults to |
... |
Additional arguments passed to |
map objectAdd a post hoc analysis function to a map object
mapAddPostHocAnalysis( map, functionName, postHocAnalysisGroups = NULL, postHocAnalyses = "all", useParallel = getOption("map.useParallel", FALSE), ... )mapAddPostHocAnalysis( map, functionName, postHocAnalysisGroups = NULL, postHocAnalyses = "all", useParallel = getOption("map.useParallel", FALSE), ... )
map |
Optional map object. If not provided, then one will be created.
If provided, then the present |
functionName |
A function that is designed for post hoc analysis of
map class objects, e.g., |
postHocAnalysisGroups |
Character string with one |
postHocAnalyses |
Character vector with |
useParallel |
Logical. If |
... |
Optional arguments to pass into |
This is the workhorse function that runs any analyses described in map@analyses.
It uses hashing, and will not rerun any analysis that already ran on identical inputs.
mapAnalysis( map, functionName = NULL, purgeAnalyses = NULL, useParallel = getOption("map.useParallel", FALSE), ... )mapAnalysis( map, functionName = NULL, purgeAnalyses = NULL, useParallel = getOption("map.useParallel", FALSE), ... )
map |
Optional map object. If not provided, then one will be created.
If provided, then the present |
functionName |
A function name that will be run on combinations of inputs in the map object. See details. |
purgeAnalyses |
A character string indicating which analysis group
combination or part thereof (e.g., the name entered into the row under
|
useParallel |
Logical. If |
... |
Additional arguments passed to:
|
This function will do a sequence of things.
First, it will run expand.grid on any columns whose names start with analysisGroup,
creating a factorial set of analyses as described by these columns.
It will assess the combinations against the arguments used by the functionName.
For any analysisGroup that does not provide the correct arguments for the functionName,
these analysisGroups will be omitted for that particular function.
For efficiency, the function will then assess if any of these has already been run.
For those that have not been run, it will then run the
functionName on arguments that it finds in the metadata slot of
the map object, as well as any arguments passed in here in the ....
In general, the arguments being passed in here should be fixed across all
analyses, while any that vary by analysis should be entered into the metadata
table at the time of adding the layer to the map, via mapAdd.
TODO
map
Remove objects from a map
mapRm(map, layer, ask = TRUE, ...) ## S3 method for class 'map' mapRm(map, layer = NULL, ask = TRUE, ...)mapRm(map, layer, ask = TRUE, ...) ## S3 method for class 'map' mapRm(map, layer = NULL, ask = TRUE, ...)
map |
TODO: document this |
layer |
TODO: document this |
ask |
TODO: document this |
... |
TODO: document this |
Other mapMethods:
crs,map-method,
rasterToMatch,map-method,
rasters(),
studyArea(),
studyAreaName()
Other mapMethods:
crs,map-method,
rasterToMatch,map-method,
rasters(),
studyArea(),
studyAreaName()
if (require("SpaDES.tools", quietly = TRUE)) { p <- terra::vect(cbind(-120, 60), crs = "epsg:4326") |> SpaDES.tools::randomPolygon(area = 1e5) |> sf::st_as_sf() |> sf::as_Spatial() m <- mapAdd(p, layerName = "p") m m <- mapRm(m, "p") m }if (require("SpaDES.tools", quietly = TRUE)) { p <- terra::vect(cbind(-120, 60), crs = "epsg:4326") |> SpaDES.tools::randomPolygon(area = 1e5) |> sf::st_as_sf() |> sf::as_Spatial() m <- mapAdd(p, layerName = "p") m m <- mapRm(m, "p") m }
Extract metadata
metadata(x, ...) ## S3 method for class 'map' metadata(x, ...) ## S3 method for class 'Map' metadata(x, ...) ## S3 method for class 'Raster' metadata(x, ...) ## S3 method for class 'SpatRaster' metadata(x, ...)metadata(x, ...) ## S3 method for class 'map' metadata(x, ...) ## S3 method for class 'Map' metadata(x, ...) ## S3 method for class 'Raster' metadata(x, ...) ## S3 method for class 'SpatRaster' metadata(x, ...)
x |
A |
... |
Additional arguments passed to other methods (not used) |
map objectrasters() extracts RasterLayer objects;
sf() extracts sf objects;
sp() extracts Spatial objects;
spatialPolygons() extracts SpatialPolygons objects;
spatialPoints() extracts SpatialPoints objects;
spatRasters() extracts SpatRaster objects;
spatVectors() extracts SpatVector objects;
This will extract all objects in or pointed to within the map.
rasters(map, ...) ## S3 method for class 'map' rasters(map, ...) sp(map, ...) ## S3 method for class 'map' sp(map, ...) sf(map, ...) ## S3 method for class 'map' sf(map, ...) spatialPolygons(map, ...) ## S3 method for class 'map' spatialPolygons(map, ...) spatialPoints(map, ...) ## S3 method for class 'map' spatialPoints(map, ...) spatRasters(map, ...) ## S3 method for class 'map' spatRasters(map, ...) spatVectors(map, ...) ## S3 method for class 'map' spatVectors(map, ...) maps(map, class = NULL, layerName = NULL)rasters(map, ...) ## S3 method for class 'map' rasters(map, ...) sp(map, ...) ## S3 method for class 'map' sp(map, ...) sf(map, ...) ## S3 method for class 'map' sf(map, ...) spatialPolygons(map, ...) ## S3 method for class 'map' spatialPolygons(map, ...) spatialPoints(map, ...) ## S3 method for class 'map' spatialPoints(map, ...) spatRasters(map, ...) ## S3 method for class 'map' spatRasters(map, ...) spatVectors(map, ...) ## S3 method for class 'map' spatVectors(map, ...) maps(map, class = NULL, layerName = NULL)
map |
A |
... |
Additional arguments passed to other methods (not used) |
class |
If supplied, this will be the class of objects returned.
Default is |
layerName |
character string giving the name(s) of layer(s) to extract. |
A list of geospatial objects of class class
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
studyArea(),
studyAreaName()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
studyArea(),
studyAreaName()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
studyArea(),
studyAreaName()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
studyArea(),
studyAreaName()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
studyArea(),
studyAreaName()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
studyArea(),
studyAreaName()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
studyArea(),
studyAreaName()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
studyArea(),
studyAreaName()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
studyArea(),
studyAreaName()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
studyArea(),
studyAreaName()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
studyArea(),
studyAreaName()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
studyArea(),
studyAreaName()
rasterToMatch(s) from a map objectIf layer is not provided and there is more than one studyArea,
then this will extract the last one added.
## S4 method for signature 'map' rasterToMatch(x, layer = 1)## S4 method for signature 'map' rasterToMatch(x, layer = 1)
x |
a |
layer |
an integer identifying the index of the |
Other mapMethods:
crs,map-method,
mapRm(),
rasters(),
studyArea(),
studyAreaName()
map objectUtility functions for grouping analyses in a map object
rbindlistAG(map, functionName, analysisGroups)rbindlistAG(map, functionName, analysisGroups)
map |
Optional map object. If not provided, then one will be created.
If provided, then the present |
functionName |
TODO: description needed |
analysisGroups |
A character (length 1 currently), indicating which
analysis group (e.g., |
A list of data.tables.
runMapAnalysesTODO: description needed
runMapAnalyses( map, purgeAnalyses = NULL, useParallel = getOption("map.useParallel", FALSE), ... )runMapAnalyses( map, purgeAnalyses = NULL, useParallel = getOption("map.useParallel", FALSE), ... )
map |
TODO |
purgeAnalyses |
TODO |
useParallel |
TODO |
... |
TODO |
TODO
Show method for map class objects
## S4 method for signature 'map' show(object)## S4 method for signature 'map' show(object)
object |
TODO: describe this |
map
If layer is not provided and there is more than one studyArea,
then this will extract the last one added.
studyArea(map, layer = NA, sorted = FALSE) ## S4 method for signature 'ANY' studyArea(map, layer = NA, sorted = FALSE) ## S4 method for signature 'map' studyArea(map, layer = NA, sorted = FALSE) studyArea(map, layer = NA) <- value ## S4 replacement method for signature 'map' studyArea(map, layer = NA) <- valuestudyArea(map, layer = NA, sorted = FALSE) ## S4 method for signature 'ANY' studyArea(map, layer = NA, sorted = FALSE) ## S4 method for signature 'map' studyArea(map, layer = NA, sorted = FALSE) studyArea(map, layer = NA) <- value ## S4 replacement method for signature 'map' studyArea(map, layer = NA) <- value
map |
TODO: document this |
layer |
TODO: document this |
sorted |
Logical. Should the numeric |
value |
The value to assign to the object. |
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
rasters(),
studyAreaName()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
rasters(),
studyAreaName()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
rasters(),
studyAreaName()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
rasters(),
studyAreaName()
Tools for getting objects and metadata in and out of a map class.
studyAreaName(x, layer, ...) ## S3 method for class 'map' studyAreaName(x, layer = 1, ...) ## S3 method for class 'data.table' studyAreaName(x, layer = 1, ...)studyAreaName(x, layer, ...) ## S3 method for class 'map' studyAreaName(x, layer = 1, ...) ## S3 method for class 'data.table' studyAreaName(x, layer = 1, ...)
x |
TODO: document this |
layer |
TODO: document this |
... |
Additional arguments passed to other methods (not used) |
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
rasters(),
studyArea()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
rasters(),
studyArea()
Other mapMethods:
crs,map-method,
mapRm(),
rasterToMatch,map-method,
rasters(),
studyArea()