Learn R Programming

chirps (version 0.1.0)

sf_to_geojson: Concatenate a sf object into a geojson polygon

Description

Take single points from geographical coordinates and convert it into a geojson 'Polygon' string using st_buffer.

Usage

sf_to_geojson(lonlat, dist = 1e-05, nQuadSegs = 2L, ...)

Arguments

lonlat

an object of class 'sf' and geometry type 'POINT' or 'POLYGON'

dist

numeric, buffer distance for all lonlat

nQuadSegs

integer, number of segments per quadrant

...

further arguments passed to sf methods

Value

An object of class 'geosjon' for each row in lonlat

See Also

Other utility functions: dataframe_to_geojson()

Examples

Run this code
# NOT RUN {
# random geographic points within bbox(10, 12, 45, 47)
library("sf")

set.seed(123)
lonlat <- data.frame(lon = runif(5, 10, 12),
                     lat = runif(5, 45, 47))

lonlat <- st_as_sf(lonlat, coords = c("lon","lat"))

gjson <- sf_to_geojson(lonlat)
# }

Run the code above in your browser using DataLab