geojsonlint tutorial

for v0.1.0

Tools for linting 'GeoJSON'.

Package API:

Installation

Stable version from CRAN

install.packages("geojsonlint")

Development version from GitHub

if (!require("devtools")) install.packages("devtools")
devtools::install_github("ropenscilabs/geojsonlint")
library("geojsonlint")

Usage

Good GeoJSON

geojsonlint.com web service

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

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

geojsonlint.com web service

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

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

geojsonlint.com web service

geojson_lint('{"type": "FooBar"}', verbose = TRUE)
#> [1] FALSE
#> attr(,"errors")
#>                                 message status
#> 1 "FooBar" is not a valid GeoJSON type.  error

geojsonhint JS library

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

is-my-json-valid JS library

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

Bad GeoJSON - stop on validation failure

geojsonlint.com web service

geojson_lint('{"type": "FooBar"}', error = TRUE)
#> Error: invalid GeoJSON
#>    - "FooBar" is not a valid GeoJSON type.

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

Citing

Scott Chamberlain and Andy Teucher (2016). geojsonlint: Tools for Validating 'GeoJSON'. R package version 0.1.0 https://cran.rstudio.com/package=geojsonlint

License and bugs

Back to top

comments powered by Disqus