1

I'm using QGIS 3.4.6, working with a big biological dataset in several shapefiles.

I want to convert the working shapefiles to CSV files, add a column with new data, then convert the CSV files back to working shapefiles.

I got the first step done (by using semicolons to separate the columns), and before I start adding data, I want to figure out how to convert them back. So, I didn't change anything from the CSV file QGIS created. I select the CSV file in the Add Delimited Text layer popup, deselect 'first record has field names' and then get stuck on the Geometry Definition options.

The CRS gets autoselected correctly, but I can't select the 'lat' and 'long' columns (thats how they're named in the CSV file), it only gives me a 'field_1' option, then tells me X and Y can't be the same.

  • 3
    why not add the new column directly to the shapefile without going to/from CSV – Ian Turton May 28 at 8:53
  • your problem is probably that your X and Y value are recognize as text and not numbers when you import back your CSV – J.R May 28 at 8:55
  • @IanTurton It's almost 4000 datapoints, I want to add a column to categorise them (the data is incomplete, I want to be able to filter on 'plants' or 'birds', right now I can only filter on one species, or build a very complex quiery every time). I figured that CSV would be easier to format, also because my future data on this project will be first entered in excel/csv format. – The Blue Pangolin May 28 at 11:37
  • 1
    you might want to look at joining csv data to shapefiles gis.stackexchange.com/questions/182281/… – Ian Turton May 28 at 12:13
  • @TheBluePangolin as you can see, some of these suggested workflows are not ideal for working with - as you call it - big data. I would suggest moving to a system like PostGIS that can easily injest both shapefiles and CSV's, update them, and allow to export back to both formats for other clients in your organization. If you need to do this type of work on a regular basis, I would highly suggest moving to PostGIS... – DPSSpatial May 28 at 16:13
0

As you can't edit data stored in a .csv with QGIS directly, i would recommend you just add the column to the shapefile. If you need to work with your data in excel or something, you can export it to csv after adding the column.

It is strange though that you can not select the columns where your lat/lon data is saved, you should be able to select any column with no regards to the name of its name.

Maybe open your .csv with a text editor (Notepad++ ). If the lat/lon coordinates are between " signs just delete 'em (search for " and replace with nothing)

I hope this solves your problem

  • Thank you @sn1ks, I'm going to try this after the weekend, I'll let you know if this was the problem! – The Blue Pangolin May 29 at 14:19
0

I think your approach of exporting/importing is longer than just joining a column to your shapefile from a table with no geometry.

From your text I understand your data are just points, assuming single-part entities. 4000 pionts should not be a big deal.

My suggestion is to:

  1. Export the data with a id and no geometry, plus the information you need to work with. Let´s call this Table1.csv
  2. Work and Table1 wherevever you need, add to it the new column and save it with as a csv file. make sure to keep the id. Let´s say Table2.csv
  3. Load Table2 as a Layer with no geometry. See How to import a non-spatial Table into QGIS?
  4. Join the Table2 with your existing shapefile. See http://www.qgistutorials.com/en/docs/performing_table_joins.html

It would be even easier if you can do the query with the data as it is, but that might require other skills you do not have yet.

  • Thank you Marco, I'm going to try this if @sn1ks solution doesn't work. I appreciate the clear step by step, now I comprehend what adding to shapefiles actually means. I will let you know if it worked! – The Blue Pangolin May 29 at 14:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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