Learn R Programming

rmapshaper (version 0.5.0)

apply_mapshaper_commands: Apply a mapshaper command string to a geojson object

Description

Apply a mapshaper command string to a geojson object

Usage

apply_mapshaper_commands(
  data,
  command,
  force_FC = TRUE,
  sys = FALSE,
  sys_mem = getOption("mapshaper.sys_mem", default = 8),
  quiet = getOption("mapshaper.sys_quiet", default = FALSE)
)

Value

geojson

Arguments

data

character containing geojson or path to geojson file. If a file path, sys must be true.

command

valid mapshaper command string

force_FC

should the output be forced to be a FeatureCollection (or sf object or Spatial*DataFrame) even if there are no attributes? Default TRUE. If FALSE and there are no attributes associated with the geometries, a GeometryCollection (or Spatial object with no dataframe, or sfc) will be output.

sys

Should the system mapshaper be used instead of the bundled mapshaper? Gives better performance on large files. Requires the mapshaper node package to be installed and on the PATH.

sys_mem

How much memory (in GB) should be allocated if using the system mapshaper (sys = TRUE)? Default 8. Ignored if sys = FALSE. This can also be set globally with the option "mapshaper.sys_mem"

quiet

If sys = TRUE, should the mapshaper messages be silenced? Default FALSE. This can also be set globally with the option "mapshaper.sys_quiet"

Examples

Run this code

nc <- sf::read_sf(system.file("gpkg/nc.gpkg", package = "sf"))
rmapshaper::apply_mapshaper_commands(geojsonsf::sf_geojson(nc), "-clean")

Run the code above in your browser using DataLab