Skip to contents

Writes the figure as one GeoJSON FeatureCollection, for a web map (MapLibre, Leaflet, OpenLayers) or a GIS: each paint operation of the figure (bands of the corridors, lines of the categories and their connectors, junctions, places, the ends at the edge of a framed map) is a feature, in paint order (properties.order), with its colour, width and what it carries (segment, flows, category, place). Labels, the title and the legend are not written; what a legend needs is in the members of the collection (categories, width_classes, honesty), and places[].uses tells which segments and categories the flows of each place use. The coordinates and lengths are in the input's coordinates (crs_name), not longitude and latitude unless the input is: reproject before using it as RFC 7946 GeoJSON. Needs flowmap(..., geojson = TRUE).

Usage

write_geojson(x, file, schematic = FALSE)

Arguments

x

A milkflow object from flowmap().

file

Path of the file to write.

schematic

Write the schematic layout instead of the geographic one; an error when there is none.

Value

file, invisibly.

Examples

m <- flowmap(demo_nodes, demo_flows, geojson = TRUE)
f <- tempfile(fileext = ".geojson")
write_geojson(m, f)
g <- jsonlite::fromJSON(f, simplifyVector = FALSE)
g$type
#> [1] "FeatureCollection"
length(g$features)
#> [1] 499
unlink(f)