Description Usage Arguments Details Value Examples
Validate GeoJSON using geojsonhint Javascript library
1 | geojson_hint(x, inform = FALSE, error = FALSE)
|
x |
Input, a geojson character string, json object, or file or url pointing to one of the former |
inform |
(logical) When geojson is invalid, return reason why
( |
error |
(logical) Throw an error on parse failure? If |
Uses the Javascript library https://www.npmjs.com/package/geojsonhint via the V8 package
TRUE
or FALSE
. If inform=TRUE
an attribute
of name errors
is added with error information
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 | geojson_hint('{"type": "FooBar"}')
geojson_hint('{ "type": "FeatureCollection" }')
geojson_hint(
'{"type":"Point","geometry":{"type":"Point","coordinates":[-80,40]},"properties":{}}'
)
# A file
file <- system.file("examples", "zillow_or.geojson", package = "geojsonlint")
geojson_hint(as.location(file))
# A URL
if (interactive()) {
url <- "https://raw.githubusercontent.com/glynnbird/usstatesgeojson/master/california.geojson"
geojson_hint(as.location(url))
}
# from json (jsonlite class)
x <- jsonlite::minify('{ "type": "FeatureCollection" }')
class(x)
geojson_hint(x)
# toggle whether reason for validation failure is given back
geojson_hint('{ "type": "FeatureCollection" }')
geojson_hint('{ "type": "FeatureCollection" }', inform = TRUE)
# toggle whether to stop with error message
geojson_hint('{ "type": "FeatureCollection" }')
geojson_hint('{ "type": "FeatureCollection" }', inform = TRUE)
if (interactive()) {
geojson_hint('{ "type": "FeatureCollection" }', error = TRUE)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.