Sf: Simple Features for R

Package `sf'

November 8, 2022

Version 1.0-9 Title Simple Features for R Description Support for simple features, a standardized way to

encode spatial vector data. Binds to 'GDAL' for reading and writing data, to 'GEOS' for geometrical operations, and to 'PROJ' for projection conversions and datum transformations. Uses by default the 's2' package for spherical geometry operations on ellipsoidal (long/lat) coordinates. License GPL-2 | MIT + file LICENSE

URL ,

BugReports Depends methods, R (>= 3.3.0) Imports classInt (>= 0.4-1), DBI (>= 0.8), graphics, grDevices, grid,

magrittr, Rcpp (>= 0.12.18), s2 (>= 1.1.0), stats, tools, units (>= 0.7-0), utils Suggests blob, covr, dplyr (>= 0.8-3), ggplot2, knitr, lwgeom (>= 0.2-1), maps, mapview, Matrix, microbenchmark, odbc, pbapply, pillar, pool, raster, rlang, rmarkdown, RPostgres (>= 1.1.0), RPostgreSQL, RSQLite, sp (>= 1.2-4), spatstat (>= 2.0-1), spatstat.geom, spatstat.random, spatstat.linnet, spatstat.utils, stars (>= 0.2-0), terra, testthat, tibble (>= 1.4.1), tidyr (>= 1.2.0), tidyselect (>= 1.0.0), tmap (>= 2.0), vctrs, wk LinkingTo Rcpp VignetteBuilder knitr Encoding UTF-8 RoxygenNote 7.2.1 SystemRequirements C++11, GDAL (>= 2.0.1), GEOS (>= 3.4.0), PROJ (>= 4.8.0), sqlite3 Collate 'RcppExports.R' 'init.R' 'crs.R' 'bbox.R' 'read.R' 'db.R' 'sfc.R' 'sfg.R' 'sf.R' 'bind.R' 'wkb.R' 'wkt.R' 'plot.R' 'geom-measures.R' 'geom-predicates.R' 'geom-transformers.R'

1

2

R topics documented:

'transform.R' 'proj.R' 'sp.R' 'grid.R' 'arith.R' 'tidyverse.R' 'tidyverse-vctrs.R' 'cast_sfg.R' 'cast_sfc.R' 'graticule.R' 'datasets.R' 'aggregate.R' 'agr.R' 'maps.R' 'join.R' 'sample.R' 'valid.R' 'collection_extract.R' 'jitter.R' 'sgbp.R' 'spatstat.R' 'stars.R' 'crop.R' 'gdal_utils.R' 'nearest.R' 'normalize.R' 'defunct.R' 'z_range.R' 'm_range.R' 'shift_longitude.R' 'make_grid.R' 's2.R' 'terra.R' 'geos-overlayng.R' 'break_antimeridian.R'

NeedsCompilation yes

Author Edzer Pebesma [aut, cre] (), Roger Bivand [ctb] (), Etienne Racine [ctb], Michael Sumner [ctb], Ian Cook [ctb], Tim Keitt [ctb], Robin Lovelace [ctb], Hadley Wickham [ctb], Jeroen Ooms [ctb] (), Kirill M?ller [ctb], Thomas Lin Pedersen [ctb], Dan Baston [ctb], Dewey Dunnington [ctb] ()

Maintainer Edzer Pebesma

Repository CRAN

Date/Publication 2022-11-08 14:20:02 UTC

R topics documented:

aggregate.sf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 as . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 bind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 dbDataType,PostgreSQLConnection,sf-method . . . . . . . . . . . . . . . . . . . . . . 8 dbWriteTable,PostgreSQLConnection,character,sf-method . . . . . . . . . . . . . . . . 8 db_drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 extension_map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 gdal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 gdal_addo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 gdal_utils . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 geos_binary_ops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 geos_binary_pred . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 geos_combine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 geos_measures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 geos_query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25 geos_unary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 internal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 interpolate_aw . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

R topics documented:

3

is_driver_available . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 is_driver_can . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 is_geometry_column . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 merge.sf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 nc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34 Ops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 prefix_map . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 proj_tools . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 rawToHex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 s2 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 sf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 sf-defunct . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47 sfc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 sf_extSoftVersion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 sf_project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49 sgbp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 st . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 stars . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 st_agr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 st_as_binary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 st_as_grob . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 st_as_sf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 st_as_sfc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 st_as_text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 st_bbox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 st_break_antimeridian . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 st_cast . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 st_cast_sfc_default . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 st_collection_extract . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 st_coordinates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 st_crop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 st_crs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 st_drivers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 st_geometry . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 st_geometry_type . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 st_graticule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 st_is . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81 st_is_longlat . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 st_jitter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 st_join . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 st_layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 st_line_sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 st_make_grid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 st_m_range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 st_nearest_feature . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 st_nearest_points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 st_normalize . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

4

aggregate.sf

st_precision . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 st_read . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94 st_relate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 st_sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 st_shift_longitude . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 st_transform . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 st_viewport . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 st_write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 st_zm . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 st_z_range . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 summary.sfc . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 tibble . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 tidyverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 transform.sf . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 valid . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120 vctrs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

Index

123

aggregate.sf

aggregate an sf object

Description aggregate an sf object, possibly union-ing geometries

Usage

## S3 method for class sf aggregate(

x, by, FUN, ..., do_union = TRUE, simplify = TRUE, join = st_intersects )

Arguments x by

FUN

object of class sf

either a list of grouping vectors with length equal to nrow(x) (see aggregate), or an object of class sf or sfc with geometries that are used to generate groupings, using the binary predicate specified by the argument join

function passed on to aggregate, in case ids was specified and attributes need to be grouped

aggregate.sf

... do_union simplify join

5

arguments passed on to FUN logical; should grouped geometries be unioned using st_union? See details. logical; see aggregate logical spatial predicate function to use if by is a simple features object or geometry; see st_join

Details

In case do_union is FALSE, aggregate will simply combine geometries using c.sfg. When polygons sharing a boundary are combined, this leads to geometries that are invalid; see https:// r-spatial/sf/issues/681.

Value

an sf object with aggregated attributes and geometries; additional grouping variables having the names of names(ids) or are named Group.i for ids[[i]]; see aggregate.

Note Does not work using the formula notation involving ~ defined in aggregate.

Examples

m1 = cbind(c(0, 0, 1, 0), c(0, 1, 1, 0)) m2 = cbind(c(0, 1, 1, 0), c(0, 0, 1, 0)) pol = st_sfc(st_polygon(list(m1)), st_polygon(list(m2))) set.seed(1985) d = data.frame(matrix(runif(15), ncol = 3)) p = st_as_sf(x = d, coords = 1:2) plot(pol) plot(p, add = TRUE) (p_ag1 = aggregate(p, pol, mean)) plot(p_ag1) # geometry same as pol # works when x overlaps multiple objects in by : p_buff = st_buffer(p, 0.2) plot(p_buff, add = TRUE) (p_ag2 = aggregate(p_buff, pol, mean)) # increased mean of second # with non-matching features m3 = cbind(c(0, 0, -0.1, 0), c(0, 0.1, 0.1, 0)) pol = st_sfc(st_polygon(list(m3)), st_polygon(list(m1)), st_polygon(list(m2))) (p_ag3 = aggregate(p, pol, mean)) plot(p_ag3) # In case we need to pass an argument to the join function: (p_ag4 = aggregate(p, pol, mean,

join = function(x, y) st_is_within_distance(x, y, dist = 0.3)))

6

as

as

Methods to coerce simple features to Spatial* and

Spatial*DataFrame objects

Description

as_Spatial() allows to convert sf and sfc to Spatial*DataFrame and Spatial* for sp compatibility. You can also use as(x, "Spatial") To transform sp objects to sf and sfc with as(x, "sf").

Usage as_Spatial(from, cast = TRUE, IDs = paste0("ID", seq_along(from)))

Arguments from cast IDs

object of class sf, sfc_POINT, sfc_MULTIPOINT, sfc_LINESTRING, sfc_MULTILINESTRING, sfc_POLYGON, or sfc_MULTIPOLYGON.

logical; if TRUE, st_cast() from before converting, so that e.g. GEOMETRY objects with a mix of POLYGON and MULTIPOLYGON are cast to MULTIPOLYGON.

character vector with IDs for the Spatial* geometries

Details

Package sp supports three dimensions for POINT and MULTIPOINT (SpatialPoint*). Other geometries must be two-dimensional (XY). Dimensions can be dropped using st_zm() with what = "M" or what = "ZM".

For converting simple features (i.e., sf objects) to their Spatial counterpart, use as(obj, "Spatial")

Value geometry-only object deriving from Spatial, of the appropriate class

Examples

nc ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download