# 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)
# }
Run the code above in your browser using DataLab