topojson_read: Read topojson from a local file or a URL

Description Usage Arguments Details Value See Also Examples

View source: R/topojson_read.R

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.

Note that this does not give you Topojson, but gives you a sp style spatial class - which you can use then to turn it into geojson as a list or json.

Value

A Spatial Class, varies depending on input

See Also

geojson_read, topojson_write

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## 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)
geojson_json(tmp)

## End(Not run)

geojsonio documentation built on Sept. 2, 2017, 1:09 a.m.