Introduction to geojsonlint

Scott Chamberlain and Andy Teucher

2020-02-12

Tools for linting ‘GeoJSON’.

GeoJSON linters available in geojsonlint

Install

Stable version from CRAN

install.packages("geojsonlint")

Development version from GitHub

remotes::install_github("ropensci/geojsonlint")
library("geojsonlint")

Good GeoJSON

geojsonhint JS library

geojson_hint(x = '{"type": "Point", "coordinates": [-100, 80]}')
#> [1] TRUE

is-my-json-valid JS library

geojson_validate(x = '{"type": "Point", "coordinates": [-100, 80]}')
#> [1] TRUE

Bad GeoJSON

geojsonhint JS library

geojson_hint('{"type": "FooBar"}')
#> [1] FALSE

is-my-json-valid JS library

geojson_validate('{ "type": "FeatureCollection" }')
#> [1] FALSE

Bad GeoJSON - with reason for failure

geojsonhint JS library

geojson_hint('{"type": "FooBar"}', inform = TRUE)
#> [1] FALSE
#> attr(,"errors")
#>   line                    message
#> 1    1 The type FooBar is unknown

is-my-json-valid JS library

geojson_validate('{ "type": "FeatureCollection" }', inform = TRUE)
#> [1] FALSE
#> attr(,"errors")
#>   field                             message
#> 1  data no (or more than one) schemas match

Bad GeoJSON - stop on validation failure

geojsonhint JS library

geojson_hint('{"type": "FooBar"}', error = TRUE)
#> Error: Line 1
#>    - The type FooBar is unknown

is-my-json-valid JS library

geojson_validate('{ "type": "FeatureCollection" }', error = TRUE)
#> Error: 1 error validating json:
#>  - data: no (or more than one) schemas match