lawn_coordeach: Iterate over property objects in any GeoJSON object

Description Usage Arguments Value Examples

View source: R/coordeach.R

Description

Iterate over property objects in any GeoJSON object

Usage

1
lawn_coordeach(x, fun = NULL, excludeWrapCoord = FALSE, lint = FALSE)

Arguments

x

any data-GeoJSON object

fun

(character) a Javascript function. if not given, returns self

excludeWrapCoord

(logical) whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration.

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
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
x <- "{ type: 'Point', coordinates: [10, 50] }"

# don't apply any function, identity essentially
lawn_coordeach(x)

# appply a function callback
lawn_coordeach(x, "z.length === 2")
lawn_coordeach(lawn_data$points_count, "z.length === 2")

z <- '{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {
        "population": 200,
        "name": "things"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [-112.0372, 46.608058]
      }
    }, {
      "type": "Feature",
      "properties": {
        "population": 600,
        "name": "stuff"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [-112.045955, 46.596264]
      }
    }
    ]
}'
lawn_coordeach(z)
lawn_coordeach(z, "z.reduce(function(a, b) { return a + b; }, 0)")

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