View source: R/filter_fields.R
ms_filter_fields | R Documentation |
Removes all fields except those listed in the fields
parameter
ms_filter_fields(input, fields, sys = FALSE, sys_mem = 8)
input |
spatial object to filter fields on. One of:
|
fields |
character vector of fields to retain. |
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 ( |
object with only specified attributes retained, in the same class as the input
library(geojsonio) library(sp) poly <- structure("{\"type\":\"FeatureCollection\", \"features\":[{\"type\":\"Feature\", \"properties\":{\"a\": 1, \"b\":2, \"c\": 3}, \"geometry\":{\"type\":\"Polygon\", \"coordinates\":[[[102,2],[102,4],[104,4],[104,2],[102,2]]]}}]}", class = c("json", "geo_json")) poly <- geojson_sp(poly) poly@data # Filter (keep) fields a and b, drop c out <- ms_filter_fields(poly, c("a", "b")) out@data
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.