Learn R Programming

osbng (version 0.2.0)

geom_to_bng: Spatial index for geometries

Description

Returns a set of BNG Reference objects given a geometry and a specified resolution.

Usage

geom_to_bng(geom, resolution, ...)

# S3 method for geos_geometry geom_to_bng(geom, resolution, ...)

# S3 method for sf geom_to_bng(geom, resolution, ...)

# S3 method for sfc geom_to_bng(geom, resolution, ...)

geom_to_bng_intersection( geom, resolution, format = c("geos", "sf", "wkt"), ... )

# S3 method for geos_geometry geom_to_bng_intersection( geom, resolution, format = c("geos", "sf", "wkt"), ... )

# S3 method for sf geom_to_bng_intersection( geom, resolution, format = c("geos", "sf", "wkt"), ... )

# S3 method for sfc geom_to_bng_intersection( geom, resolution, format = c("geos", "sf", "wkt"), ... )

Value

geom_to_bng: list of vectors of BNGReference objects where the number of items in the list equal length(geom).

geom_to_bng_intersection: list of nested lists with length(geom). Each nested list contains three named items:

  • "BNGReference" - BNGReference objects representing the grid squares corresponding to the decomposition.

  • "is_core" - logical vector indicating whether the grid square geometry is entirely contained by the input geometry. This is relevant for Polygon geometries and helps distinguish between "core" (fully inside) and "edge" (partially overlapping) grid squares.

  • "geom" - The geometry representing the intersection between the input geometry and the grid square. This can one of a number of geometry types depending on the overlap. When "is_core" is TRUE, "geom" is the same as the grid square geometry.

Arguments

geom

geometry object of type geos-geometry or sf

resolution

spatial resolution of the BNG cell expressed in string or integer values

...

additional parameters. Not currently used.

format

character indicating the type of geometry object to return. Default is "geos" while "sf" returns a geometry object of class sfc.

Details

The BNG Reference objects returned represent the grid squares intersected by the input geometry. BNG Reference objects are de-duplicated in cases where two or more parts of a multi-part geometry intersect the same grid square.

Unlike geom_to_bng which only returns BNG Reference objects representing the grid squares intersected by the input geometry, geom_to_bng_intersection returns list objects that store the intersection between the input geometry and the grid square geometries.

These functions are useful for spatial indexing and aggregation of geometries against the BNG. For geometry decomposition by the BNG index system, use geom_to_bng_intersection instead.

See Also

geom_to_bng_intersection_explode()

Examples

Run this code
geom_to_bng(geos::geos_make_point(430000, 110000), "100km")

geom_to_bng(geos::geos_make_linestring(c(430000, 430010, 430010), c(110000,
110000, 110010)), "5m")

geom_to_bng_intersection(geos::geos_make_point(430000, 110000), "100km")

geom_to_bng_intersection(geos::geos_make_linestring(c(430000, 430010,
430010), c(110000, 110000, 110010)), "5m")

geom_to_bng_intersection(geos::geos_make_polygon(c(375480.64511692,
426949.67604058, 465166.20199588, 453762.88376729, 393510.2158297,
375480.64511692), c(144999.23691181, 160255.02751493, 153320.57724078,
94454.79935802, 91989.21703833, 144999.23691181)), "50km")

Run the code above in your browser using DataLab