Description Usage Arguments Details Value References Examples
View source: R/geojson_validate.R
Validate GeoJSON using is-my-json-valid Javascript library
1 | geojson_validate(x, inform = FALSE, error = FALSE, greedy = 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 |
greedy |
(logical) Continue after the first error? |
Sometimes you may get a response that your input GeoJSON is
invalid, but get a somewhat unhelpful error message, e.g.,
no (or more than one) schemas match
. See
https://github.com/ropensci/geojsonlint/issues/7#issuecomment-219881961.
We'll hopefully soon get this sorted out so you'll get a meaningful error
message. However, this method is faster than the other two methods in
this package, so there is that.
TRUE
or FALSE
. If inform=TRUE
an attribute
of name errors
is added with error information
https://www.npmjs.com/package/is-my-json-valid
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 | # From a json character string
## good
geojson_validate('{"type": "Point", "coordinates": [-100, 80]}')
## bad
geojson_validate(
'{"type": "Rhombus", "coordinates": [[1, 2], [3, 4], [5, 6]]}')
# A file
file <- system.file("examples", "zillow_or.geojson",
package = "geojsonlint")
geojson_validate(x = as.location(file))
# A URL
if (interactive()) {
url <- "https://raw.githubusercontent.com/glynnbird/usstatesgeojson/master/california.geojson"
geojson_validate(as.location(url))
}
# toggle whether reason for validation failure is given back
geojson_validate('{ "type": "FeatureCollection" }')
geojson_validate('{ "type": "FeatureCollection" }', inform = TRUE)
# toggle whether to stop with error message
geojson_validate('{ "type": "FeatureCollection" }')
geojson_validate('{ "type": "FeatureCollection" }', inform = TRUE)
if (interactive()) {
geojson_validate('{ "type": "FeatureCollection" }', error = TRUE)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.