lawn_getcoord: Unwrap a coordinate from a Feature with a Point geometry, or...

View source: R/getcoord.R

lawn_getcoordR Documentation

Unwrap a coordinate from a Feature with a Point geometry, or a single coordinate.

Description

Unwrap a coordinate from a Feature with a Point geometry, or a single coordinate.

Usage

lawn_getcoord(x, lint = FALSE)

Arguments

x

any data-GeoJSON object

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

matrix of coordinates, where each row in the matrix is a coordinate pair

Examples

x <- "{ type: 'Point', coordinates: [10, 50] }"
lawn_getcoord(x)

library(jsonlite)
x <- fromJSON(lawn_data$points_count, FALSE)$features
lawn_getcoord(x[[1]])
lawn_getcoord(x[[2]])
lawn_getcoord(x[[1]]$geometry)
lawn_getcoord(x[[1]]$geometry$coordinates)

# fails
# lawn_getcoord(x[[1]]$geometry$coordinates[[1]])

ropensci/lawn documentation built on May 18, 2022, 9:58 a.m.