Learn R Programming

geojsonio (version 0.1.8)

validate: Validate a geoJSON file, json object, list, or Spatial class.

Description

Validate a geoJSON file, json object, list, or Spatial class.

Usage

validate(x, ...)

Arguments

x
Input list, data.frame, or spatial class. Inputs can also be dplyr tbl_df class since it inherits from data.frame.
...
Further args passed on to helper functions.

Details

Uses the web service at http://geojsonlint.com/

Examples

Run this code
## Not run: 
# # From a json character string
# validate(x = '{"type": "Point", "coordinates": [-100, 80]}') # good
# validate(x = '{"type": "Rhombus", "coordinates": [[1, 2], [3, 4], [5, 6]]}') # bad
# 
# # A file
# file <- system.file("examples", "zillow_or.geojson", package = "geojsonio")
# validate(x = as.location(file))
# 
# # A URL
# url <- "https://raw.githubusercontent.com/glynnbird/usstatesgeojson/master/california.geojson"
# validate(as.location(url))
# 
# # From output of geojson_list
# (x <- geojson_list(us_cities[1:2,], lat='lat', lon='long'))
# validate(x)
# 
# # From output of geojson_json
# (x <- geojson_json(us_cities[1:2,], lat='lat', lon='long'))
# validate(x)
# 
# # From a list turned into geo_list
# mylist <- list(list(latitude=30, longitude=120, marker="red"),
#                list(latitude=30, longitude=130, marker="blue"))
# x <- geojson_list(mylist)
# class(x)
# validate(x)
# 
# # From SpatialPoints class
# library("sp")
# a <- c(1,2,3,4,5)
# b <- c(3,2,5,1,4)
# (x <- SpatialPoints(cbind(a,b)))
# class(x)
# validate(x)
# ## End(Not run)

Run the code above in your browser using DataLab