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
Run the code above in your browser using DataLab