I converted a shapefile into a CSV in order to do some calculations with the data and add some columns to the attribute table. I cannot seem to find out how to convert it to a geolocalized file again? I have lat and long coordinates but I am working with polygons delimited as c- squares.
-
3How did you convert to CSV? Do you know how to load a CSV into QGIS? Why didn't you do the calculations in QGIS?– ErikCommented Dec 6, 2021 at 16:27
-
gis.stackexchange.com/questions/179827/… please see this query– GeographosCommented Dec 6, 2021 at 16:28
-
@MKR: the linked question is about ArcGIS, the OP here asks for QGIS. However, Erik is right, calculations should be done in QGIS.– BabelCommented Dec 6, 2021 at 16:35
-
Shapefiles are a bundle of several files. One of them is the attribute table. Have you converted only this file to CSV?– AshCommented Dec 6, 2021 at 16:55
-
Don't try to retroject your CSV, but join your new attributes (calculations) with the ID to your original shapefile.– katagenaCommented Dec 6, 2021 at 18:40
|
Show 3 more comments
1 Answer
From your comments, I see you using R so I suggest to use the {sf}
package. You don't even need to convert to between csv and shapefile, {sf}
+ {dplyr}
allow you to read shapefiles, do some calculations and save results as another shapefile.
An example would be:
library(sf)
library(dplyr)
my_sf_data <- st_read(<your shapefile>)
results <- my_sf_data %>%
filter(...) %>% # or any dplyr action
mutate(...)
st_write(results, <new shapefile>)