# Soil and plant masking w/ Pix4Dfields

**URL:** <https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300>\
**Category:** Workflow and Application\
**Created:** [April 9, 2020, 12:31pm UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300 "2020-04-09T12:31:23Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fernanda\_Bosmediano](https://sea2.discourse-cdn.com/pix4d/user_avatar/community.pix4d.com/fernanda_bosmediano/32/323_2.png) [@Fernanda\_Bosmediano](https://community.pix4d.com/u/Fernanda_Bosmediano)\
**Post date:** [April 9, 2020, 12:31pm UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/1 "2020-04-09T12:31:24Z")

</div>

**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**

Formula:

(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

 ![](https://global.discourse-cdn.com/pix4d/original/2X/5/5c7998ecb5fc92ec22b29eef0f1ae8d368c7f912.jpeg)

 ![](https://global.discourse-cdn.com/pix4d/original/2X/d/d10bf7e19fdee326833446cb570a4208cf0e51ce.png)

**Vegetation masked map**

Formula:

(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

 ![](https://global.discourse-cdn.com/pix4d/original/2X/c/c8c3d4a54ee6a2af9c18d40887377fa75dbe54ea.jpeg)

 ![](https://global.discourse-cdn.com/pix4d/original/2X/1/17438748b7d83dfe97a8b91cb3805410b005a9be.png)

**Vegetation map within a specific range**

Formula:

(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

 ![](https://global.discourse-cdn.com/pix4d/original/2X/5/5581b860f2c3a497120742d2f8866e74a0af2737.png)

---

<div class="post-metadata">

**Author:** ![jerimiah](https://avatars.discourse-cdn.com/v4/letter/j/f07891/32.png) [@jerimiah](https://community.pix4d.com/u/jerimiah)\
**Post date:** [April 17, 2020, 2:30pm UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/2 "2020-04-17T14:30:32Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![momtanu.chakraborty](https://sea2.discourse-cdn.com/pix4d/user_avatar/community.pix4d.com/momtanu.chakraborty/32/269_2.png) [@momtanu.chakraborty](https://community.pix4d.com/u/momtanu.chakraborty)\
**Post date:** [April 18, 2020, 12:20am UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/3 "2020-04-18T00:20:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Steve\_Wagner](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@Steve\_Wagner](https://community.pix4d.com/u/Steve_Wagner)\
**Post date:** [April 21, 2020, 1:25pm UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/4 "2020-04-21T13:25:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![newtech.crieppam](https://avatars.discourse-cdn.com/v4/letter/n/977dab/32.png) [@newtech.crieppam](https://community.pix4d.com/u/newtech.crieppam)\
**Post date:** [April 21, 2020, 7:56pm UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/5 "2020-04-21T19:56:57Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![momtanu.chakraborty](https://sea2.discourse-cdn.com/pix4d/user_avatar/community.pix4d.com/momtanu.chakraborty/32/269_2.png) [@momtanu.chakraborty](https://community.pix4d.com/u/momtanu.chakraborty)\
**Post date:** [April 21, 2020, 8:11pm UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/6 "2020-04-21T20:11:29Z")

</div>

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) - #2 by momtanu.chakraborty](https://community.pix4d.com/t/pix4d-indicies-formula-kent-index/9881/2), you can have a look.

---

<div class="post-metadata">

**Author:** ![sesekeh180](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@sesekeh180](https://community.pix4d.com/u/sesekeh180)\
**Post date:** [May 17, 2020, 3:24am UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/7 "2020-05-17T03:24:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Fernanda\_Bosmediano](https://sea2.discourse-cdn.com/pix4d/user_avatar/community.pix4d.com/fernanda_bosmediano/32/323_2.png) [@Fernanda\_Bosmediano](https://community.pix4d.com/u/Fernanda_Bosmediano)\
**Post date:** [May 18, 2020, 10:44am UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/8 "2020-05-18T10:44:54Z")

</div>

Hey,

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

Regards,

---

<div class="post-metadata">

**Author:** ![sesekeh180](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@sesekeh180](https://community.pix4d.com/u/sesekeh180)\
**Post date:** [May 21, 2020, 3:49am UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/9 "2020-05-21T03:49:03Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![momtanu.chakraborty](https://sea2.discourse-cdn.com/pix4d/user_avatar/community.pix4d.com/momtanu.chakraborty/32/269_2.png) [@momtanu.chakraborty](https://community.pix4d.com/u/momtanu.chakraborty)\
**Post date:** [May 21, 2020, 6:14pm UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/10 "2020-05-21T18:14:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sesekeh180](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@sesekeh180](https://community.pix4d.com/u/sesekeh180)\
**Post date:** [May 21, 2020, 10:27pm UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/11 "2020-05-21T22:27:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![momtanu.chakraborty](https://sea2.discourse-cdn.com/pix4d/user_avatar/community.pix4d.com/momtanu.chakraborty/32/269_2.png) [@momtanu.chakraborty](https://community.pix4d.com/u/momtanu.chakraborty)\
**Post date:** [May 21, 2020, 11:35pm UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/12 "2020-05-21T23:35:02Z")

</div>

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: [Pix4Dfields Feature Request - Pix4D Community](https://community.pix4d.com/c/pix4dfields/Pix4DfieldsFR/81)?

---

<div class="post-metadata">

**Author:** ![sesekeh180](https://avatars.discourse-cdn.com/v4/letter/s/ecae2f/32.png) [@sesekeh180](https://community.pix4d.com/u/sesekeh180)\
**Post date:** [May 22, 2020, 5:25am UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/13 "2020-05-22T05:25:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![momtanu.chakraborty](https://sea2.discourse-cdn.com/pix4d/user_avatar/community.pix4d.com/momtanu.chakraborty/32/269_2.png) [@momtanu.chakraborty](https://community.pix4d.com/u/momtanu.chakraborty)\
**Post date:** [May 23, 2020, 12:57am UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/14 "2020-05-23T00:57:36Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ag2ab.inc](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@ag2ab.inc](https://community.pix4d.com/u/ag2ab.inc)\
**Post date:** [August 14, 2021, 12:26am UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/15 "2021-08-14T00:26:26Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Fernanda\_Bosmediano](https://sea2.discourse-cdn.com/pix4d/user_avatar/community.pix4d.com/fernanda_bosmediano/32/323_2.png) [@Fernanda\_Bosmediano](https://community.pix4d.com/u/Fernanda_Bosmediano)\
**Post date:** [August 24, 2021, 9:26am UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/16 "2021-08-24T09:26:58Z")

</div>

> [@Fernanda\_Bosmediano](#):
>
> (nir-red)/(nir+red) + 0/max(0; (nir-red)/(nir+red) - 0.4) + 0/min(0; (nir-red)/(nir+red) - 0.6)

Hi,

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.

---

<div class="post-metadata">

**Author:** ![ag2ab.inc](https://avatars.discourse-cdn.com/v4/letter/a/ee7513/32.png) [@ag2ab.inc](https://community.pix4d.com/u/ag2ab.inc)\
**Post date:** [August 24, 2021, 3:59pm UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/17 "2021-08-24T15:59:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Fernanda\_Bosmediano](https://sea2.discourse-cdn.com/pix4d/user_avatar/community.pix4d.com/fernanda_bosmediano/32/323_2.png) [@Fernanda\_Bosmediano](https://community.pix4d.com/u/Fernanda_Bosmediano)\
**Post date:** [August 26, 2021, 6:26am UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/18 "2021-08-26T06:26:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![amerykd](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@amerykd](https://community.pix4d.com/u/amerykd)\
**Post date:** [September 13, 2021, 12:26am UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/19 "2021-09-13T00:26:44Z")

</div>

> [@Fernanda\_Bosmediano](#):
>
> (nir-red)/(nir+red) + 0/min(0; (nir-red)/(nir+red) - 0.4)

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.

---

<div class="post-metadata">

**Author:** ![Fernanda\_Bosmediano](https://sea2.discourse-cdn.com/pix4d/user_avatar/community.pix4d.com/fernanda_bosmediano/32/323_2.png) [@Fernanda\_Bosmediano](https://community.pix4d.com/u/Fernanda_Bosmediano)\
**Post date:** [September 16, 2021, 11:49am UTC](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300/20 "2021-09-16T11:49:11Z")

</div>

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](https://drive.google.com/drive/folders/1av2ZqmNhkm9KlYUKnrq-bRtNRyOcf2F6?usp=sharing)

[Next page](https://community.pix4d.com/t/soil-and-plant-masking-w-pix4dfields/12300.md?page=2)
