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

Description Usage Arguments Value Examples

View source: R/getcoord.R

Description

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

Usage

1
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
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]])

lawn documentation built on Jan. 6, 2021, 5:07 p.m.