Is there a way to add an "M" coordinate (dimension) to an sf object in R? As far as I can tell, currently, only the "Z" coordinate can be added using the "st_zm()" function.
I would use sfheaders:
pt <- sf::st_sf(st_sfc(st_point(cbind(1, 1)))) ## convert to data frame df <- sfheaders::sf_to_df(pt) df$m <- 0 ## add M sfheaders::sf_pt(df) Simple feature collection with 1 feature and 0 fields geometry type: POINT dimension: XYM ...
You'll have to carry the crs over (use
st_crs()<-) and handle other fields, but you can use
sfheaders::sfc_* functions to create just the geometry column, and replace that.