spatial_engine {ursa} | R Documentation |
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) spatial_dir(path = ".", pattern = NA, full.names = TRUE, recursive = FALSE) spatial_basename(fname) is_spatial(obj, verbose = FALSE) is_spatial_points(obj, verbose = FALSE) is_spatial_lines(obj, verbose = FALSE) is_spatial_polygons(obj, verbose = FALSE) spatial_intersection(x, y, verbose = FALSE) spatial_symdifference(x, y, verbose = FALSE) spatial_union(x, y, byid=NA, verbose = FALSE) spatial_buffer(obj, dist = 0, quadsegs = 30L, verbose = FALSE)
obj |
Simple feature (package sf) or Spatial abstract class (package sp) for all functions, excepting |
x, y |
Objects of simple feature (package sf) class or Spatial abstract class (package sp). |
crs |
Projection EPSG code or projection PROJ.4 string. |
subset |
Pattern to field names (colnames) of attribute table (data frame) for subbsetting using |
drop |
Logical. Dropping column of data frame. If |
value |
Value for property assignment in replacement functions. Either numeric EPSG code or character PROJ.4 string for |
path |
See description of argument |
pattern |
See description of argument |
full.names |
See description of argument |
recursive |
See description of argument |
quadsegs |
Integer. Number of segments per quadrant (fourth of a circle), for all or per-feature. See description for |
dist |
Numeric. Buffer distance for all, or for each of the elements. See description for |
byid |
Logical. For |
fname |
Character. Filename (source or packed) of spatial data. |
verbose |
Logical. Value |
... |
Further arguments passed to |
.
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
and its synonym spatial_dir
return list of files with file extensions, which are associated with certain GIS vector formats. The function's basis is dir
.
spatial_basename
returns basename (without extension) of file fname
of spatial object.
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.
spatial_intersection
returns intersection of two spatial objects.
spatial_symdifference
returns difference of two spatial objects.
spatial_buffer
returns buffered spatial object.
spatial_union
returns combined geometry without internal boundaries.
The great improvement for development of functions for manipulation with spatial objects has been reached during work in series of projects (2015-2018) for design of marine protected areas in the Arctic, which were supported by WWF Russia.
Nikita Platonov platonov@sevin.ru
Classes and methods in packages sf and sp help.
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)) }