These wrappers return iniform properties or do consimilar manipulations for spatial objects of different types: simple features (package sf) and abstract class Spatial (package sp). Appropriate functionality (“engine”) of respective packages is used.
spatial_engine(obj, verbose = FALSE)spatial_crs(obj, verbose = FALSE)
spatial_proj4(obj, verbose = FALSE)
spatial_crs(obj, verbose = FALSE) <- value
spatial_proj4(obj, verbose = FALSE) <- value
spatial_bbox(obj, verbose = FALSE)
spatial_bbox(obj, verbose = FALSE) <- value
spatial_data(obj, subset= ".+", drop = NA, verbose = FALSE)
spatial_data(obj, verbose = FALSE) <- value
spatial_geometry(obj, verbose = FALSE)
spatial_geometry(obj, verbose = FALSE) <- value
spatial_geotype(obj, verbose = FALSE)
spatial_transform(obj, crs, verbose = FALSE, ...)
spatial_coordinates(obj, verbose = FALSE)
spatial_fields(obj, verbose = FALSE)
spatial_colnames(obj, verbose = FALSE)
spatial_fields(obj, verbose = FALSE) <- value
spatial_colnames(obj, verbose = FALSE) <- value
spatial_area(obj, verbose = FALSE)
spatial_dim(obj, verbose = FALSE)
spatial_count(obj, verbose = FALSE)
spatial_nrow(obj, verbose = FALSE)
spatial_ncol(obj, verbose = FALSE)
spatial_filelist(path = ".", pattern = NA, full.names = TRUE, recursive = FALSE)
is_spatial(obj, verbose = FALSE)
is_spatial_points(obj, verbose = FALSE)
is_spatial_lines(obj, verbose = FALSE)
is_spatial_polygons(obj, verbose = FALSE)
Simple feature (package sf) or Spatial abstract class (package sp) for all functions, excepting spatial_geometry<-
. Data frame for Replace function spatial_geometry<-
.
Projection EPSG code or projection PROJ.4 string.
Pattern to field names (colnames) of attribute table (data frame) for subbsetting using regular expressions
. By default, all fields are secected.
Logical. Dropping column of data frame. If TRUE
, then vector of data is returned. If FALSE
, then structure of data is kept. Default is NA
, which is interpreted as TRUE
for single column and as FALSE
for multiple columns.
Value for property assignment in replacement functions. Either numeric EPSG code or character PROJ.4 string for spatial_crs<-
and spatial_proj4<-
. Spatial object or geometry of spatial object for spatial_geometry<-
.
See description of argument path
in function dir
.
See description of argument pattern
in function dir
.
See description of argument full.names
in function dir
.
See description of argument full.names
in function dir
.
Logical. Value TRUE
provides information on console. Default is FALSE
.
Further arguments passed to sf::st_transform
or to sp::spTransform
spatial_engine
returns package name (character string "sf"
or "sp"
), which functionality is used for manipulation with spatial object obj
.
spatial_crs
and spatial_proj4
are synonyms, The Extract functions return projection string in the PROJ.4 notation; the Replace functions change projection property of the object.
spatial_bbox
(Extract function) returns numeric vector of length 4 with names "xmin", "ymin", "xmax" and "ymax".
spatial_bbox<-
(Replace function) assigns boundary bbox to the object; it is valid only for objects of Spatial abstract class (package sp).
spatial_data
(Extract function) returns attribute table only, without geometry. Subsetting fields can be specified by argument subset
using regular expressions. If drop=TRUE
and selected single column then vector is returned instead of data frame.
spatial_data<-
(Replace function) addes spatial data to the object geomerty. Source data (if presents) are droped.
spatial_geometry
(Extract function) returns only geometry, which format is depended on class of obj
.
spatial_geometry<-
(Replace function) addes geometry to the object.
spatial_transform
does a transformation of spatial coordinates to the new CRS and returns object of the same class as class of obj
.
spatial_geotype
returns type of spatial data: "POINTS", "LINESTRINGS", "POLYGON", "MULTIPOLYGON", ….
spatial_coordinates
returns simpliefied matrix or list of coordinates of original object.
Extract functions spatial_fields
and spatial_columns
return column names of spatial attributive table. spatial_columns
is synonym to spatial_fields
.
Replace functions spatial_fields<-
and spatial_columns<-
change column names of spatial attributive table. spatial_columns<-
is synonym to spatial_fields<-
.
spatial_area
is valid for polygonal geometry. It returns area of polygons.
spatial_length
is valid for linear geometry. It returns length of lines.
spatial_dim
gets dimension of spatial coordinates; it returns either 2L
(XY) or 3L
(XYZ).
spatial_count
returns number of items of object geometry.
spatial_nrow
and spatial_ncol
return number of rows and number of columns of attributive table.
spatial_filelist
returns list of files with file extensions, which are associated with certain GIS vector formats. The function's basis is dir
.
is_spatial
returns logical value does the object belong to the class of spatial data.
is_spatial_points
returns logical value does the object have point geometry.
is_spatial_lines
returns logical value does the object have (multi)linestring geometry.
is_spatial_polygons
returns logical value does the object have (multi)polygonal geometry.
# NOT RUN {
session_grid(NULL)
n <- 1e2
x <- runif(n,min=25,max=65)
y <- runif(n,min=55,max=65)
z <- runif(n,min=1,max=10)
da <- data.frame(x=x,y=y,z=z)
if (requireNamespace("sp")) {
da.sp <- da
sp::coordinates(da.sp) <- ~x+y
sp::proj4string(da.sp) <- "+init=epsg:4326"
print(spatial_bbox(da.sp))
print(spatial_crs(da.sp))
}
if (requireNamespace("sf")) {
da.sf <- sf::st_as_sf(da,coords=c("x","y"),crs=4326)
print(spatial_bbox(da.sf))
print(spatial_crs(da.sf))
}
# }
Run the code above in your browser using DataCamp Workspace