FROM_GeoJson: reads GeoJson data

Description Usage Arguments Details Value Examples

View source: R/utils.R

Description

reads GeoJson data

Usage

1
2
FROM_GeoJson(url_file_string, Flatten_Coords = FALSE,
  Average_Coordinates = FALSE, To_List = FALSE)

Arguments

url_file_string

a string specifying the input path to a file OR a geojson object (in form of a character string) OR a valid url (beginning with 'http..') pointing to a geojson object

Flatten_Coords

either TRUE or FALSE. If TRUE then the properties member of the geojson file will be omitted during parsing.

Average_Coordinates

either TRUE or FALSE. If TRUE then additionally a geojson-dump and the average latitude and longitude of the geometry object will be returned.

To_List

either TRUE or FALSE. If TRUE then the coordinates of the geometry object will be returned in form of a list, otherwise in form of a numeric matrix.

Details

The FROM_GeoJson function is based on the 'RFC 7946' specification. Thus, geojson files/strings which include property-names other than the 'RFC 7946' specifies will return an error. To avoid errors of that kind a user should take advantage of the FROM_GeoJson_Schema function, which is not as strict concerning the property names.

Value

a (nested) list

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
library(geojsonR)


# INPUT IS A FILE

# Do not run

# res = FROM_GeoJson(url_file_string = "/myfolder/feature_collection.geojson")


# INPUT IS A GEOJSON (character string)

tmp_str = '{ "type": "MultiPolygon", "coordinates": [
  [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],
  [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],
   [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]
  ]
}'

res = FROM_GeoJson(url_file_string = tmp_str)


# INPUT IS A URL

# Do not run

# res = FROM_GeoJson(url_file_string = "http://www.EXAMPLE_web_page.geojson")

geojsonR documentation built on Sept. 23, 2018, 5:05 p.m.