I am using QGIS 2.14 to open NC files for chlorophyll satellite data with the end goal of compiling chlorophyll values for many dates (each its own initial file) in a spreadsheet. I know how to do the work manually, but I want to automate the process in the model due to the bulk of files I am working with.

Currently, my process is to manually open each file in QGIS, then I have been using the model. I run zonal statistics for each file based on the study area, then I add a date attribute in each file. My problem is that I can't figure out how to fill in the date values (using the format 2000_01, 2000_02, etc) using field calculator or advanced python field calculator. I need the date attributes in order to merge the files for export.

I think this would be possible in ArcMap, so can I do it in QGIS with minimal/no python?

I've included the model that I've started with.enter image description here

  • How do you know what date to use for the current layer? Is it a property of the layer, or do you want to manually enter it when you run the model? – csk Jun 7 '19 at 17:01
  • The data is available online for specific dates, so I select the dates then and name the files based on the date selected. Each initial file can only correspond to one date. – jfsmith Jun 7 '19 at 17:40

Create a new string input, called date. Set the default value to YYYY_MM - this will indicate to the user of the model what format they should use to input the date.

enter image description here

Use the Field Calculator algorithm instead of the Add field to attribute table algorithm. For the formula, use either @date or parameter('date').

enter image description here

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.