FROM_GeoJson_Schema {geojsonR}R Documentation

reads GeoJson data using a one-word-schema

Description

reads GeoJson data using a one-word-schema

Usage

FROM_GeoJson_Schema(
  url_file_string,
  geometry_name = "",
  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

geometry_name

a string specifying the geometry name in the geojson string/file. The geometry_name functions as a one-word schema and can significantly speed up the parsing of the data.

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

This function is appropriate when the property-names do not match exactly the 'RFC 7946' specification ( for instance if the geometry object-name appears as location as is the case sometimes in mongodb queries ). The user can then specify the geometry_name as it exactly appears in the .geojson string/file (consult the example for more details). If no geometry_name is given then recursion will be used, which increases the processing time. In case that the input .geojson object is of type : Point, LineString, MultiPoint, Polygon, GeometryCollection, MultiLineString, MultiPolygon, Feature or FeatureCollection with a second attribute name : coordinates, then the geometry_name parameter is not necessary.

Value

a (nested) list

Examples


library(geojsonR)


# INPUT IS A GEOJSON (character string)

tmp_str = '{
            "name" : "example_name",
            "location" : {
                "type" : "Point",
                "coordinates" : [ -120.24, 39.21 ]
              }
           }'

res = FROM_GeoJson_Schema(url_file_string = tmp_str, geometry_name = "location")


[Package geojsonR version 1.1.1 Index]