0

I am trying to load Geojson string into R, which was stored as a character string in CSV and then declare it as geojson by as.geojson function. But the json validation is failing as shown.

>   geo2_geojson <- geojson::as.geojson(test1)

Error in geojson::as.geojson(test1) : jsonlite::validate(x) is not TRUE

I tried different ways of declaring it as geojson, but was unsuccessful. Can someone help me in solving this issue or Please free to suggest any efficient method if any knows.

Dinesh
  • 391
  • 2
  • 9
  • 2
    Maybe past an extract of the data you are trying to parse and look up the workings of `validate()`. – Philipp R Dec 29 '18 at 00:50
  • Without an extract of the data to check, the fact that `jsonlite::validate() is not TRUE` means it is likely that the string is not a valid JSON string. [Source](https://rdrr.io/cran/jsonlite/man/validate.html) – g_t_m Dec 29 '18 at 04:55
  • Without seeing your data it's impossible to help. The error is telling you your string is not valid JSON. And, even if it were, GeoJSON has its [own specification](https://tools.ietf.org/html/rfc7946), so manually setting it's class as `geojson` may not be appropriate either. – SymbolixAU Dec 29 '18 at 05:04
  • 1
    the geojson is invalid, i just made a change in `geojson` - install `remotes::install_github("ropensci/geojson")`, and try it again, should throw the error now from `jsonlite` – sckott Dec 29 '18 at 06:40
  • Thanks @sckott. Its working with the new package install. – Dinesh Dec 31 '18 at 16:45

0 Answers0