Description Usage Arguments Value Examples
Converts a geoJSON string to a spatial object using the readOGR function from the rgdal package.
1 | geojson2SPDF(geoJSONstr, ...)
|
geoJSONstr |
str, a valid geoJSON string in a character vector of length 1. |
... |
, additional parameters passed to readOGR |
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.
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))
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.