Soil and plant masking w/ Pix4Dfields

Modified: 1-27-2021 Hello, we are updating some information according to your questions.

Besides the generation of standard vegetation indices, the use of the index calculator allows us to generate a custom index that adapts better to their specific crop scouting or crop protection needs.

Some of you asked about soil masking; vegetation masking or generating maps within a certain threshold. Currently, the following workaround can be used:

  1. Process your images and get the orthomosaic
  2. Generate a vegetation index
  3. Using the histogram equalization of the advanced visualization tool identifies the values that are from your interest.
  4. Go to the Index Generator tool
  5. Click on “Create Custom Index”
  6. Enter the formula of your index

As an example, we have generated an NDVI index, and we are assuming that plants have an NDVI value of more than 0.4. Therefore, we have used formulas that use a division by zero to cause transparency on pixels with lower and higher values than 0.4 and mask soil or vegetation respectively.

You can adapt this idea using other bands and values.

Soil masked map


(nir-red)/(nir+red) + 0/max(0; (nir-red)/(nir+red) - 0.4)

Note: In this formula, using max() will mask everything lower than 0.4. This value 0.4 can be modified depending on your applications

Vegetation masked map


(nir-red)/(nir+red) + 0/min(0; (nir-red)/(nir+red) - 0.4)

Note: In this formula, using min() will mask everything higher than 0.4. This value 0.4 can be modified depending on your applications

Vegetation map within a specific range


(nir-red)/(nir+red) + 0/max(0; (nir-red)/(nir+red) - 0.4) + 0/min(0; (nir-red)/(nir+red) - 0.6)

Note: In this formula, using max() will mask everything lower than 0.4, and using min() will mask everything higher than 0.6

Is it possible to edit the algorithm to display the reflectance between a certain threshold? For example if i wanted to display values between 0.8 and 0.9.

1 Like

Hi Jeremiah, We are coming up with that featuire very soon :slight_smile:

Is it possible to do this in Pix4D Mapper or is this exclusive to fields?

Hello Steve.
I tried with Fields and it works perfectly. I wanted to do it with Mapper, but it didn’t recognize the Min and Max functions (or I got it wrong …).
A solution available for Mapper?

Hi all, We do not have the min, max functions in Mapper. You can try using QGIS/ArcGIS on any raster calculator that has the min, max functions. I had also answered here: Pix4D indicies formula (kent index), you can have a look.

In this formula you wrote:

(nir-red)/(nir+red) + 0/min(0; (nir-red)/(nir+red) - 0.4) - NDVI

You used all this formula and then made it minus the NDVI? Is this correct? I am having a sintax error when copying the formula. If I erase only the “NDVI” ot Works as a formula, but does not work as a mask right. Any ideas?

1 Like


You should not minus the NDVI. I am modifying the text, so it is not confusing. Thanks so much for the feedback.


Is there a way to edit this formula to show only a specified range of vegetation? Ie.: from 0.7 to 0.9
And is there a way for doing that with the soil range also?

Gustavo, You can get the index from 0.7 to 1. Here we substract 0.4, since we are assuming the plants have NDVI value more than 0.4, so all the pixels below 0.4 are masked. If you use 0.7, the pixel value (NDVI) below 0.7 will be masked. But there is no way to change the max value. We are brining a feature very soon where you will be able to chnage the max, min values (range) of any index. 0.4 is the threshold value here and you could chnage it to any value according to your application.

The reason I am asking you that is because I would like to remove/mask some trees that are scattered acrross a crop field, and I realized they have a signature that ranges from 0.8 to 1.

In this next uptade to come, will we be able to customize the range of vegetation on the zonation maps also? This would also be a way to eliminate this scattered trees, and would also allow us to specify weed infestation signatures inside a crop.

So you will need to use this: (nir-red)/(nir+red) + 0/min(0; (nir-red)/(nir+red) - 0.8). That will mask all the vegetation NDVI ranging from 0.8 to 1.

The range of max, min in zonation maps will not be there yet. However, I will pass on the request to our team. Could you also make a feature request here:

great, but how about if the vegetation that i wanted to mask was only between 0,8 to 0,9?

You will not be able to do it with this formula but as I said, this feature is coming very soon. For now, you can try it in QGIS. You will be able to chnage the max, min values of the map.

Hi, For this function,
How can calculate the soil mask area size of total?
For example, the soil mask all soil, then how many percentage of total NDVI?
Thank you.


Calculating the area of the soil is not yet possible with PIX4Dfields. However, I passed your feedback to the team. Meanwhile, you can import our outputs to QGIS and calculate the area there.

Is that possible to use zone function to calculate the area of soil?

You will get an estimation but we havent tested it, so I would not recommend it at this moment. You can give it a try. First mask the vegetation, and then generate a zonation map and see the area. But for now, to be sure I would recommend using QGIS.

Hi, Is there a way to reduce size of zonation? for example i’m trying to generate a zonation map for where individual weeds are, however zonation does huge areas instead. I’ve tried the formulas above which helped a bit but still way too large.

Unfortunately not inside PIX4Dfields. However, you can take out outputs and do that with QGIS for example.

Maybe this gives you an idea of the workflow: 86960 - Google Drive