as.feature: Coerce character strings or JSON to GeoJSON Feature

Description Usage Arguments Value Examples

View source: R/as.feature.R

Description

Coerce character strings or JSON to GeoJSON Feature

Usage

1

Arguments

x

a character string or json class with a GeoJSON object, any of feature, point, multipoint, linestring, multilinestring, polygon, or multipolygon. featurecollection and geometrycollection simply returned without alteration

...

ignored

Value

a feature class object

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
poly <- '{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "Polygon",
    "coordinates": [[
      [105.818939,21.004714],
      [105.818939,21.061754],
      [105.890007,21.061754],
      [105.890007,21.004714],
      [105.818939,21.004714]
     ]]
  }
}'
as.feature(poly)

pt <- '{"type":"Point","coordinates":[-75.343,39.984]}'
as.feature(pt)

line <- '{
  "type": "LineString",
  "coordinates": [
    [-77.031669, 38.878605],
    [-77.029609, 38.881946],
    [-77.020339, 38.884084],
    [-77.025661, 38.885821],
    [-77.021884, 38.889563],
    [-77.019824, 38.892368]
    ]
}'
as.feature(line)

# returns self if no match - note "Points" is not a GeoJSON type
pt <- '{"type":"Points","coordinates":[-75.343,39.984]}'
as.feature(pt)

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