sf | R Documentation |
sf
methods for sfnetwork
objects.
## S3 method for class 'sfnetwork'
st_as_sf(x, active = NULL, ...)
## S3 method for class 'sfnetwork'
st_as_s2(x, active = NULL, ...)
## S3 method for class 'sfnetwork'
st_geometry(obj, active = NULL, ...)
## S3 replacement method for class 'sfnetwork'
st_geometry(x) <- value
## S3 method for class 'sfnetwork'
st_drop_geometry(x, ...)
## S3 method for class 'sfnetwork'
st_bbox(obj, active = NULL, ...)
## S3 method for class 'sfnetwork'
st_coordinates(x, active = NULL, ...)
## S3 method for class 'sfnetwork'
st_is(x, ...)
## S3 method for class 'sfnetwork'
st_is_valid(x, ...)
## S3 method for class 'sfnetwork'
st_crs(x, ...)
## S3 replacement method for class 'sfnetwork'
st_crs(x) <- value
## S3 method for class 'sfnetwork'
st_precision(x)
## S3 method for class 'sfnetwork'
st_set_precision(x, precision)
## S3 method for class 'sfnetwork'
st_shift_longitude(x, ...)
## S3 method for class 'sfnetwork'
st_transform(x, ...)
## S3 method for class 'sfnetwork'
st_wrap_dateline(x, ...)
## S3 method for class 'sfnetwork'
st_normalize(x, ...)
## S3 method for class 'sfnetwork'
st_zm(x, ...)
## S3 method for class 'sfnetwork'
st_m_range(obj, active = NULL, ...)
## S3 method for class 'sfnetwork'
st_z_range(obj, active = NULL, ...)
## S3 method for class 'sfnetwork'
st_agr(x, active = NULL, ...)
## S3 replacement method for class 'sfnetwork'
st_agr(x) <- value
## S3 method for class 'sfnetwork'
st_reverse(x, ...)
## S3 method for class 'sfnetwork'
st_simplify(x, ...)
## S3 method for class 'sfnetwork'
st_join(x, y, ...)
## S3 method for class 'morphed_sfnetwork'
st_join(x, y, ...)
## S3 method for class 'sfnetwork'
st_filter(x, y, ...)
## S3 method for class 'morphed_sfnetwork'
st_filter(x, y, ...)
## S3 method for class 'sfnetwork'
st_crop(x, y, ...)
## S3 method for class 'morphed_sfnetwork'
st_crop(x, y, ...)
## S3 method for class 'sfnetwork'
st_difference(x, y, ...)
## S3 method for class 'morphed_sfnetwork'
st_difference(x, y, ...)
## S3 method for class 'sfnetwork'
st_intersection(x, y, ...)
## S3 method for class 'morphed_sfnetwork'
st_intersection(x, y, ...)
## S3 method for class 'sfnetwork'
st_intersects(x, y, ...)
## S3 method for class 'sfnetwork'
st_sample(x, ...)
## S3 method for class 'sfnetwork'
st_nearest_points(x, y, ...)
## S3 method for class 'sfnetwork'
st_area(x, ...)
x |
An object of class |
active |
Which network element (i.e. nodes or edges) to activate before
extracting. If |
... |
Arguments passed on the corresponding |
obj |
An object of class |
value |
The value to be assigned. See the documentation of the corresponding sf function for details. |
precision |
The precision to be assigned. See
|
y |
An object of class |
See the sf
documentation.
The sfnetwork
method for st_as_sf
returns
the active element of the network as object of class sf
.
The sfnetwork
and morphed_sfnetwork
methods for
st_join
, st_filter
,
st_intersection
, st_difference
,
st_crop
and the setter functions
return an object of class sfnetwork
and morphed_sfnetwork
respectively. All other
methods return the same type of objects as their corresponding sf function.
See the sf
documentation for details.
library(sf, quietly = TRUE)
net = as_sfnetwork(roxel)
# Extract the active network element.
st_as_sf(net)
# Extract any network element.
st_as_sf(net, "edges")
# Get geometry of the active network element.
st_geometry(net)
# Get geometry of any network element.
st_geometry(net, "edges")
# Get bbox of the active network element.
st_bbox(net)
# Get CRS of the network.
st_crs(net)
# Get agr factor of the active network element.
st_agr(net)
# Get agr factor of any network element.
st_agr(net, "edges")
# Spatial join applied to the active network element.
net = st_transform(net, 3035)
codes = st_as_sf(st_make_grid(net, n = c(2, 2)))
codes$post_code = as.character(seq(1000, 1000 + nrow(codes) * 10 - 10, 10))
joined = st_join(net, codes, join = st_intersects)
joined
oldpar = par(no.readonly = TRUE)
par(mar = c(1,1,1,1), mfrow = c(1,2))
plot(net, col = "grey")
plot(codes, col = NA, border = "red", lty = 4, lwd = 4, add = TRUE)
text(st_coordinates(st_centroid(st_geometry(codes))), codes$post_code)
plot(st_geometry(joined, "edges"))
plot(st_as_sf(joined, "nodes"), pch = 20, add = TRUE)
par(oldpar)
# Spatial filter applied to the active network element.
p1 = st_point(c(4151358, 3208045))
p2 = st_point(c(4151340, 3207520))
p3 = st_point(c(4151756, 3207506))
p4 = st_point(c(4151774, 3208031))
poly = st_multipoint(c(p1, p2, p3, p4)) %>%
st_cast('POLYGON') %>%
st_sfc(crs = 3035) %>%
st_as_sf()
filtered = st_filter(net, poly, .pred = st_intersects)
oldpar = par(no.readonly = TRUE)
par(mar = c(1,1,1,1), mfrow = c(1,2))
plot(net, col = "grey")
plot(poly, border = "red", lty = 4, lwd = 4, add = TRUE)
plot(filtered)
par(oldpar)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.