View source: R/topojson_write.R
topojson_write | R Documentation |
Write TopoJSON from various inputs
topojson_write(
input,
lat = NULL,
lon = NULL,
geometry = "point",
group = NULL,
file = "myfile.topojson",
overwrite = TRUE,
precision = NULL,
convert_wgs84 = FALSE,
crs = NULL,
object_name = "foo",
quantization = 0,
...
)
input |
Input list, data.frame, spatial class, or sf class.
Inputs can also be dplyr |
lat |
(character) Latitude name. The default is |
lon |
(character) Longitude name. The default is |
geometry |
(character) One of point (Default) or polygon. |
group |
(character) A grouping variable to perform grouping for polygons - doesn't apply for points |
file |
(character) A path and file name (e.g., myfile), with the
|
overwrite |
(logical) Overwrite the file given in |
precision |
desired number of decimal places for the coordinates in the geojson file. Using fewer decimal places can decrease file sizes (at the cost of precision). |
convert_wgs84 |
Should the input be converted to the
standard CRS for GeoJSON (https://tools.ietf.org/html/rfc7946)
(geographic coordinate reference
system, using the WGS84 datum, with longitude and latitude units of decimal
degrees; EPSG: 4326). Default is |
crs |
The CRS of the input if it is not already defined. This can be
an epsg code as a four or five digit integer or a valid proj4 string. This
argument will be ignored if |
object_name |
(character) name to give to the TopoJSON object created. Default: "foo" |
quantization |
(numeric) quantization parameter, use this to
quantize geometry prior to computing topology. Typical values are powers of
ten ( |
... |
Further args passed on to internal functions. For Spatial*
classes, data.frames,
regular lists, and numerics, it is passed through to
|
Under the hood we simply wrap geojson_write()
, then
take the GeoJSON output of that operation, then convert to TopoJSON with
geo2topo()
, then write to disk.
Unfortunately, this process requires a number of round trips to disk, so speed ups will hopefully come soon.
Any intermediate geojson files are cleaned up (deleted).
A topojson_write
class, with two elements:
path: path to the file with the TopoJSON
type: type of object the TopoJSON came from, e.g., SpatialPoints
geojson_write()
, topojson_read()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.