how to upload shapefile and merge with csv in rshiny

Uploading a shapefile - especially the ESRI Shapefile with shp extension - can be tricky, as they are often spread across multiple files.

For an example known to work consider this earlier post ShinyFiles and shapefiles? - #5 by fiorepalombina

As for joining the shapefile - once digested by the {sf} package, e.g. via sf::st_read() call from a tempdir or what not - there should be no shiny specific issues: a code that runs in your R local session should run the same in a shiny app (my suggestion for joining by a common key would be start with your shapefile and do a dplyr::left_join() using a common key; that way the resulting object will inherit the "special sauce" (= sticky geometry) from your first argument.

1 Like