geojson_hint | R Documentation |
Validate GeoJSON using geojsonhint Javascript library
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
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.