0

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.

8
  • 3
    How did you convert to CSV? Do you know how to load a CSV into QGIS? Why didn't you do the calculations in QGIS?
    – Erik
    Commented Dec 6, 2021 at 16:27
  • gis.stackexchange.com/questions/179827/… please see this query
    – Geographos
    Commented 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.
    – Babel
    Commented 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?
    – Ash
    Commented 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.
    – katagena
    Commented Dec 6, 2021 at 18:40

1 Answer 1

2

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>)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.