2

I have a shapefile given to me by our GIS Tech. It represents a pipeline gathering system and contains one layer. The Attribute Table contains many columns of information, some of which are incomplete. I want to update the information in those columns which are incomplete.

The four columns in question are named MATERIAL, NOMINAL_DI, PIPE_GRADE, and WT. I want to update WT (wall thickness). I used the Expression Builder and was able to pull a subset of the pipes like this:

"MATERIAL" ILIKE '%POLY%' AND
"PIPE_GRADE" ILIKE '%17%' AND
"NOMINAL_DI" = '6'

I was then able to manually update the WT field. However, there are many combinations and I would like to automate this process. How would I modify the filter to update that WT field? Or would I need to write a python script to do this?

As far as my experience level goes, I am not experienced with Python at all, to be honest, but this would be a great opportunity for me to start learning. (My programming experience is with Fortran and VBA.) I ran through most of the QGIS Training webpages, until I determined that the answer to my question wasn't addressed there (or I was too obtuse to pick up on it, heh).

4
  • You have to update (write an expression) manually if there is no pattern in combinations. Commented Jan 4, 2022 at 20:25
  • 1
    I guess I don't understand what you mean by "pattern in combinations"? Would you elaborate on that please? If I had to write this in VBA, it would be something like (assuming we could have a Collection of 'pipes') For Each pipe in pipes If Material = Poly and Pipe_Grade = 17 and Nominal_DI = 6 Then WT = 0.390 Next
    – Matt Greer
    Commented Jan 4, 2022 at 22:00
  • Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works
    – Ian Turton
    Commented Jan 5, 2022 at 9:28
  • You just mentioned one condition as an expression. The example in your comment is a pattern, for example. I meant that. Commented Jan 5, 2022 at 15:47

1 Answer 1

2

In Expression Builder, this is the equivalent of your VBA script: ( I assume all three fields are string)

if("MATERIAL" ILIKE '%POLY%' AND "PIPE_GRADE" ILIKE '%17%' AND "NOMINAL_DI" = '6',
   0.390,
   NULL)
1
  • Thank you! I copy/pasted that into the expression builder, but, it doesn't seem to want to run through all the records. I hit the 'Apply' button but, it didn't do anything. Should the expression read, after the '6', '"WT" = 0.390' I tried that, but it didn't run through the records to update that field. I apologize for my lack of understanding here and I appreciate your continued assistance!
    – Matt Greer
    Commented Jan 6, 2022 at 14:29

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.