3

I want to create a new vector layer with polygons in it. I've an Excel file with the columns that have to be the attributes in the layer's attribute table. How do I achieve this?

I'm kinda lost, I managed to get the Excel file into QGIS, but I'm not allowed to edit it. Once I export it to KML, it becomes a point layer and although I can edit it, all the polygon tools are inactive. What am I missing?

2 Answers 2

2

Advice

Your question seems quite basic, so I advice you to have a look at some tutorials (like Klas Karlsson's QGIS 3 for Absolute Beginners), books (like Kurt Menke's Discover QGIS 3.x) and the QGIS documentation - I added a few links below. There are many more great resources out there.

The Problem

Excel files, CSV data, KML etc. are file formats that have limited editing functionality in QGIS: you can't edit them or just in a reduced form.

How to solve it

To edit geometries (like polygons) you must use a GIS format like Geopackage or Shapefiles. Create a new, empty layer, toggle editing mode and draw your polygons. You can pre-define a number of attributes that you can fill in when you finish drawing a feature or you can add attributes later using the attribute table and field calculator - or even filling in the table manually.

If you already have attribute data in an excel file, you can load that to QGIS and make a table join, joining the attributes to the polygons. However, you need a common, unique identifier that tells QGIS which line in the excel sheet should be connected to which polygon.

The attributes in this way are only joined to the vector layer and you can't edit them. To cahnge values, you still must do it in the excel file. To be able to edit the attributes, export the joined layer to a new (Geopackage) file - this way, you'll get "real" attributes you can edit.

3
  • Yes, well, it's quite basic, I agree. So, now I've created the shapefile, and joined it to the Excel. I've also created polygons to my liking. The thing is now, although the atribute table has the right structure with the right columns from Excel, I cannot edit it. Only field I can edit is the ID field, and others are not editable. Yes, I toggled the edit mode on, yes, I gave both the shapefile and the excel file Write permissions in the Windows interface. Could it be, that since the files are just joined, I cannot edit the excel file from Qgis?
    – edge
    Commented Aug 24, 2021 at 6:32
  • Is there a way to "import" the excel column structure in the shapefile atribute table so that it'd be "native" rather than "joined"? This seems like a labyrinth to me, as far as I understand, the atribute table is not meant to be edited by hand in the first place. How can I edit interactively atributes of polygons inside Qgis?
    – edge
    Commented Aug 24, 2021 at 6:39
  • I added the answer to your first question to the initial answer (see at the bottom). You can edit the attribute table manually, but in many cases, you want to do this automatically. To do so, use field calculator (see link in the answer) - you can create new fields or change (edit) existing fields. You must define an expression that creates the values for each feature of the field.
    – Babel
    Commented Aug 24, 2021 at 6:50
2

Yes, well, I finally solved it. Thanks everyone for the help! The solution was far from intuitive. It appears first I join empty, newly created shapefile with the corresponding Excel, and then export the shapefile to another one, and now I can edit the values in the atribute table like I'd expect. As to polygons - it seems they can be created either in the empty shapefile before exporting or after, in the final shapefile already. In my case editing the values had to be done exclusively manually. So I just toggle the edit button in the exported shapefile and I was good to go. Of course I stumbled upon another counterintuitive hassle - although in the new, joined shapefile the names of the fields from Excel appeared correct, after exporting they all got clipped to max 10 characters. I spent a good half an hour just to realize that it's somewhere deep inside the shapefile format, and it actually cannot be solved. So I just left it as is, hopefully my client`ll be able to deal with it.

1
  • Yes, shapefiles have many limitations. That's why if possible, better use Geopackage. With this format, you don't have these kind of limitations.
    – Babel
    Commented Aug 24, 2021 at 8:15

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.