-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dealing with invalid GeoJSON #137
Comments
cc @ateucher |
moving to next milestone - played around with this a bit, but it's complicated since at least with here's what i tried: #' @export
geojson_read.character <- function(x, method = "web", parse = FALSE, what = "list", ...) {
lint_geojson(x)
read_json(as.location(x), method, parse, what, ...)
}
lint_geojson <- function(x) {
if (inherits(x, "character")) {
if (file.exists(x)) {
geojsonlint::geojson_validate(unclass(x), error = TRUE)
}
}
if (inherits(x, "location_")) {
if (attr(x, "type") == "file") {
geojsonlint::geojson_validate(unclass(x), error = TRUE)
}
}
}
#' @export
geojson_read.location_ <- function(x, method = "web", parse = FALSE, what = "list", ...) {
lint_geojson(x)
read_json(x, method, parse, what, ...)
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
arose from https://stackoverflow.com/questions/50240935/removing-brackets-from-ends-of-geojson-in-r
With the
bad.txt
file below, which contains JSON, rgdal fails without a helpful message:With
good.txt
it works fine:Options:
geojsonlint
to lint json to attempt to make sure the json is valid geojsonIf we use
geojsonlint
bad
bad.txt
good
good.txt
The text was updated successfully, but these errors were encountered: