Read topojson from a local file or a URL

Share:

Description

Read topojson from a local file or a URL

Usage

1

Arguments

x

Path to a local file or a URL.

...

Further args passed on to readOGR

Details

Returns a Spatial class (e.g., SpatialPolygonsDataFrame), but you can easily and quickly get this to geojson, see examples

Value

A Spatial Class, varies depending on input

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
## Not run: 
# From a file
file <- system.file("examples", "us_states.topojson", package = "geojsonio")
topojson_read(file)

# From a URL
url <- "https://raw.githubusercontent.com/shawnbot/d3-cartogram/master/data/us-states.topojson"
topojson_read(url)

# Use as.location first if you want
topojson_read(as.location(file))

# quickly convert to geojson as a list
file <- system.file("examples", "us_states.topojson", package = "geojsonio")
tmp <- topojson_read(file)
geojson_list(tmp)

## End(Not run)

Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.