Learn R Programming

lawn (version 0.5.0)

lawn_tag: Spatial join of points and polygons

Description

Takes a set of data-Point's and a set of data-Polygon's and performs a spatial join.

Usage

lawn_tag(points, polygons, field, out_field, lint = FALSE)

Arguments

field

Property in polygons to add to joined Point features.

out_field

Property in points in which to store joined property from polygons.

lint

(logical) Lint or not. Uses geojsonhint. Takes up increasing time as the object to get linted increases in size, so probably use by default for small objects, but not for large if you know they are good geojson objects. Default: FALSE

Value

Points with containing_polyid property containing values from poly_id, as data-FeatureCollection<(data-Point)>

See Also

Other joins: lawn_inside, lawn_within

Examples

Run this code
# NOT RUN {
bbox <- c(0, 0, 10, 10)
pts <- lawn_random(n = 30, bbox = bbox)
polys <- lawn_triangle_grid(bbox, 50, 'miles')
polys$features$properties$fill <- "#f92"
polys$features$properties$stroke <- 0
polys$features$properties$`fill-opacity` <- 1
lawn_tag(pts, polys, 'fill', 'marker-color')
# }
# NOT RUN {
lawn_tag(pts, polys, 'fill', 'marker-color') %>% view
# }

Run the code above in your browser using DataLab