geojson2SPDF: Converts A geoJSON string to a Spatial Object

Description Usage Arguments Value Examples

View source: R/geojson2SPDF.R

Description

Converts a geoJSON string to a spatial object using the readOGR function from the rgdal package.

Usage

1
geojson2SPDF(geoJSONstr, ...)

Arguments

geoJSONstr

str, a valid geoJSON string in a character vector of length 1.

...

, additional parameters passed to readOGR

Value

A spatial object with class coresponding to the class of the equivilent geoJSON object type.

A spatial object with class coresponding to the class of the equivilent geoJSON object type.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
# Make a simple polygon object
simplePolygon <- '{
"type": "Polygon",
"coordinates": [
    [
        [-64.73, 32.31],
        [-80.19, 25.76],
        [-66.09, 18.43],
        [-64.73, 32.31]
        ]
    ]
}'

# transform it to spatial polygon and plot
sp::plot(geojson2SPDF(simplePolygon, verbose=FALSE))

nmmarquez/shapecode documentation built on May 29, 2019, 9:15 a.m.