View source: R/editAttributes.R
editAttributes | R Documentation |
Launches a 'shiny' application where you can add and edit spatial geometry and attributes. Geometry is created or edited within the interactive map, while feature attributes can be added to and edited within the editable table.
Starting with a 'data.frame' or an 'sf data.frame', a list of 'sf data.frames' or nothing at all. You can add columns, and rows and geometry for each row. Clicking on a row with geometry you can zoom across the map between features.
When you are done, your edits are saved to an 'sf data.frame' for use in R or to be saved to anyformat you wish via st_write.
The application can dynamically handle: character, numeric, integer, factor and date fields.
When the input data set is an 'sf data.frame' the map automatically zooms to the extent of the 'sf' object.
When the input has no spatial data, you must tell the function where to zoom. The function uses geocode_OSM to identify the coordinates of your area of interest.
editAttributes( dat, zoomto = NULL, col_add = TRUE, reset = TRUE, provider = "Esri.WorldImagery", testing = FALSE )
dat |
input data source, can be a 'data.frame' or an 'sf data.frame', or it can be left empty. When nothing is passed to 'dat' a basic 'data.frame' is generated with 'id' and 'comment' fields. |
zoomto |
character area of interest. The area is defined using geocode_OSM, which uses OSM Nominatim. The area can be as ambiguous as a country, or as specific as a street address. You can test the area of interest using the application or the example code below. |
col_add |
boolean option to enable add columns form. Set to false if you don't want to allow a user to modify the data structure. |
reset |
boolean option to reset attribute input. Set to false if you don't want the attribute input to reset to NA after each added row. Use this option when features share common attributes |
provider |
A character string indicating the provider tile of choice, e.g. 'Esri.WorldImagery' (default) |
sf data.frame
Editing of feature geometries does not work for multi-geometry inputs. For this use case it is advisable to split the data set by geometry type and edit separately
## Not run: # with no input data_sf <- editAttributes(zoomto = 'germany') # a data.frame input dat <- data.frame(name = c('SiteA', 'SiteB'), type = factor(c('park', 'zoo'), levels = c('park', 'factory', 'zoo', 'warehouse')), size = c(35, 45)) data_sf <- editAttributes(dat, zoomto = 'berlin') # an sf data.frame input data_sf <- editAttributes(data_sf) # test zoomto area of interest zoomto_area <- tmaptools::geocode_OSM('paris') mapview(st_as_sfc(zoomto_area$bbox)) ## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.