# NOT RUN {
file <- system.file("examples", "norway_maple.kml", package = "geojsonio")
# KML type file - using the web method
file_to_geojson(input=file, method='web', output='kml_web')
## read into memory
file_to_geojson(input=file, method='web', output = ":memory:")
file_to_geojson(input=file, method='local', output = ":memory:")
# KML type file - using the local method
file_to_geojson(input=file, method='local', output='kml_local')
# Shp type file - using the web method - input is a zipped shp bundle
file <- system.file("examples", "bison.zip", package = "geojsonio")
file_to_geojson(file, method='web', output='shp_web')
# Shp type file - using the local method - input is the actual .shp file
file <- system.file("examples", "bison.zip", package = "geojsonio")
dir <- tempdir()
unzip(file, exdir = dir)
list.files(dir)
shpfile <- file.path(dir, "bison-Bison_bison-20130704-120856.shp")
file_to_geojson(shpfile, method='local', output='shp_local')
# US National Weather Service Hydrologic service area boundaries
url <- 'https://www.weather.gov/source/gis/Shapefiles/Misc/hs05jn19.zip'
out <- file_to_geojson(input=url, method='web', output='hsa')
# geojson with .json extension
## this doesn't work anymore, hmmm
# x <- gsub("\n", "", paste0('https://gist.githubusercontent.com/hunterowens/
# 25ea24e198c80c9fbcc7/raw/7fd3efda9009f902b5a991a506cea52db19ba143/
# wards2014.json', collapse = ""))
# res <- file_to_geojson(x)
# jsonlite::fromJSON(res)
# res <- file_to_geojson(x, method = "local")
# jsonlite::fromJSON(res)
# }
Run the code above in your browser using DataLab