0

I am using QGIS 2.18.11 and I have a shape layer with lines and polylines I need to review; but not all of them, only certain ones. The ones I need to review are marked in a specific field (rev = 0 or rev = 1) in an Excel file (.xlxs). Both data files share the same ID, so I could connect them.

How I would normally do this is performing a join in my shapefile with the Excel file using the ID; then I would add a new field in the shapefile and update it with the "rev" field data; I would then close the excel file so I can keep on working on it in parallel; finally I would filter my shapefile with "rev"=1, and there I have the lines and polylines I need to review.

Is there a faster way? Also a way that does not make me edit the shapefile (by creating that "rev" field)?

0

If you can connect the shapefile with Excel file using join by attribute, then you can simply save the joined file as a new shapefile and the link will exist permanently.

In this case, Rev field which exist in Excel file will be written / transferred to shapefile and you can filter the new shapefile by Rev field.

  • Thanks, yes that's another way. It is only that I didn't want to generate more files, nor modify the existing shape files, as I only need to "see" the line, but the change will be performed in the excel file. – Pescariz Oct 18 '18 at 8:03
0

You can temporary join table to your shapefile via Joins tab in layer properties.

  1. save your table as .csv
  2. load the CSV using Add Delimited Text Layer...
  3. go to Joins tab in shapefile layer properites, and hit the + button
  4. make a join by setting your id

enter image description here

Done, the CSV values append to your shapefile remaining in CSV (not writing to shapefile). You can also edit the CSV values in external spreadsheet editor (Calc, Excel, etc.). When you remove the CSV from your QGIS project, the connection (attributes from shapefile) is also removed.

  • Thanks. That is simmilar to what @ahmadhanb suggested. I think it can be done skipping the CSV step. Still, I would then have to do the filter step to keep on working, and I was looking for something more straightforward. – Pescariz Oct 18 '18 at 8:22
0

The only faster way of doing this beyond the other answers is to automate it using python/pyqgis (creating the join, iterating through the join layer and looking for successfully joined features, and commuting the attribute edit). Here's a tutorial on the joining part.

https://www.qgistutorials.com/en/docs/performing_table_joins_pyqgis.html

The other parts you should be able to find more code examples by using various keyword searches like "pyqgis commit edit" or "pyqgis get layer features".

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.