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, ...)
input |
spatial object to filter fields on. One of:
|
fields |
character vector of fields to retain. |
... |
Arguments passed on to
|
object with only specified attributes retained, in the same class as the input
library(geojsonsf)
library(sf)
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("geojson", "json"))
poly <- geojson_sf(poly)
poly
# Filter (keep) fields a and b, drop c
out <- ms_filter_fields(poly, c("a", "b"))
out
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.