You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the bad.txt file below, which contains JSON, rgdal fails without a helpful message:
library(rgdal)
rgdal::readOGR("bad.txt", rgdal::ogrListLayers("bad.txt"))
#> Error in rgdal::ogrListLayers("bad.txt") : Cannot open data source# sf similarly doesn't give a helpful errorsf::st_read("bad.txt")
#> Cannot open data source /Users/sckott/github/ropensci/geojsonio/bad.txt#> Error in CPL_read_ogr(dsn, layer, as.character(options), quiet, type, :#> Open failed.
With good.txt it works fine:
rgdal::readOGR("good.txt", rgdal::ogrListLayers("good.txt"))
#> OGR data source with driver: GeoJSON#> Source: "/Users/sckott/github/ropensci/geojsonio/good.txt", layer: "OGRGeoJSON"#> with 1 features#> It has 51 fields#> An object of class "SpatialPolygonsDataFrame"#> Slot "data":#> ...# sf works fine with good datasf::st_read("good.txt")
Options:
Use our pkg geojsonlint to lint json to attempt to make sure the json is valid geojson
don't do anything - check on a case by case basis as users report errors? and could document that users should check that their GeoJSON is valid.
any others?
If we use geojsonlint
# good (should all be TRUE, can check to see why hint is not working)geojsonlint::geojson_hint(as.location('good.txt'))
#> [1] FALSEgeojsonlint::geojson_lint(as.location('good.txt'))
#> [1] TRUEgeojsonlint::geojson_validate(as.location('good.txt'))
#> [1] TRUE# bad (should all be FALSE)geojsonlint::geojson_hint(as.location('bad.txt'))
#> [1] FALSEgeojsonlint::geojson_lint(as.location('bad.txt'))
#> [1] FALSEgeojsonlint::geojson_validate(as.location('bad.txt'))
#> [1] FALSE
moving to next milestone - played around with this a bit, but it's complicated since at least with geosjon_read a user can pass in files and urls, each with various extensions, so makes it quite complicated. e.g. we'd not want to lint a kml file or a shp file
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: