geo_line_distance: Calculate length of GeoJSON LineString or Polygon

Description Usage Arguments Value Examples

View source: R/line_distance.R

Description

FIXME: doesn't support FeatureCollection's yet - fix c++ code

Usage

1
geo_line_distance(line, units = "kilometers")

Arguments

line

a LineString to measure

units

(character) Can be degrees, radians, miles, or kilometers (default)

Value

Single numeric value

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
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
# LineString
line <- '{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "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]
    ]
  }
}'

geo_line_distance(line)
geo_line_distance(line, units = "miles")
geo_line_distance(line, units = "degrees")
geo_line_distance(line, units = "radians")

# Polygon
x <- '{"type":"Feature","properties":{},"geometry":{"type":"Polygon",
"coordinates":[[[-67.031021,10.458102],[-67.031021,10.53372],
[-66.929397,10.53372],[-66.929397,10.458102],[-67.031021,10.458102]]]}}'

geo_line_distance(x)

# MultiPolygon
x <- '{
  "type": "Feature",
  "properties": {},
  "geometry": {
    "type": "MultiPolygon",
    "coordinates": [
      [
        [
          [
            -122.62527465820311,
            37.89327929625019
          ],
          [
            -122.60467529296875,
            37.902490518640995
          ],
          [
            -122.58682250976562,
            37.895988598965644
          ],
          [
            -122.62527465820311,
            37.89327929625019
          ]
        ]
      ],
      [
        [
          [
            -122.52639770507812,
            37.83473402375478
          ],
          [
            -122.53395080566405,
            37.83690319650768
          ],
          [
            -122.51541137695311,
            37.83473402375478
          ],
          [
            -122.52639770507812,
            37.83473402375478
          ]
        ]
      ],
      [
        [
          [
            -122.44331359863283,
            37.726194088705576
          ],
          [
            -122.47833251953125,
            37.73651223296987
          ],
          [
            -122.43095397949219,
            37.74411415606583
          ],
          [
            -122.40898132324217,
            37.77505678240509
          ],
          [
            -122.4103546142578,
            37.72184917678752
          ],
          [
            -122.44331359863283,
            37.726194088705576
          ]
        ]
      ]
    ]
  }
}'

geo_line_distance(x)

ropenscilabs/geoops documentation built on Jan. 1, 2021, 4:03 p.m.