 Hello, welcome back on my YouTube channel. In today's video we're going to calculate NDVI and Zonal statistics. I'm using the same dataset as last video, so with parcels and aerial photographs for an area in the Netherlands. I installed a stack API browser from the Plugins Manager. Stack stands for Spatial Temporal Asset Catalog. And with this icon I can open the stack API browser dialog that gives us access to different resources stack APIs. And I'm going to use here the Microsoft Planetary Computer stack API. As you see it has access to a lot of datasets and I'm using here Sentinel-2 level 2a. I'm going to filter by date and I'm going to look for a recent image, so for February 2023 and also for a specific extent. And I can use here the extent of the bookmark that we made in the previous video. Then I hit search. Most results here are with a lot of clouds, but this image here of 14 February looks quite okay. So let's load this one. I can click few assets and there I can see which bands are available. I can load them as individual bands and I can add them as a layer or I can download them to a file. Here I just want to calculate NDVI, so I'm simply going to add band 8, which is near infrared and band 4, which is red, and then make the resolutions to our map canvas by clicking add selected assets as layers. And there I see the bands. Now I can easily calculate the NDVI using the raster calculator. Open the raster calculator from the raster menu and there I compose the expression, which is band 8 minus band 4 divided by band 8 plus band 4. And applying the correct brackets, I see expression valid. So I define the output layer and the code NDVI February 2023. Toptif, hit save, and I run the raster calculator. This takes some time. The resulting NDVI layer has a question mark, which means that the CRS, the coordinate reference system, is unknown. So I'm going to set the layer CRS, which should be the same as from the satellite image that we downloaded, and that is, I will show you in a bit, UTM zone 31 north. So I use here the EPS code for zone 31 north, accept the transformation, and I'm going to show you how I know that I just hover my mouse over one of the bands and there I see brackets, the projection. So now the projection is correct and it has been loaded in the correct position. So I can now export also this layer to the correct projection and clip it to the right size. So I call the output now NDVI February 2023 RD for the name of the projection. I change it to the projection of the project and I use the larger study area bookmark. I could also use the map canvas extent and I define the resolution there as 10 by 10 meters, which was also the resolution in UTM, and I define here a no data value just to make sure that it doesn't use zero if there's no data, and there's our result. Let's reorganize the layers a bit. I'm going to hide all the layers and move the parcels to the top, so I only have the parcels over the NDVI data, and let's style the NDVI data. In the layer styling panel I choose single-band pseudo color so I can choose a ramp. This default ramp is not the one I want to use, so I go to all color ramps and I want one that goes from red to green. That's this one, red, yellow, green. So in green we see the parcels with high NDVI and in red with the low ones and yellow in between. This is nice but it's also useful to have statistics per parcels. I go to the processing toolbox and then the raster analysis I find the tool Zonal Statistics, which requires as an input layer a polygon layer, in this case the parcels layer and a raster layer. I use the NDVI in the dash projection. You can see the EPSG code in brackets next to the layer and it's good practice that you use the same projection. If you're not using the same this tool will reproject and re-sample one to the other but it's better to have control on that. Therefore I recommend to reproject to the same projection before running this tool. I gave output prefix for the attributes NDVI underscore and then I choose here the statistics that I want to add which is the mean standard deviation minimum and maximum. I save the result to a geopackage. Here I use an existing one from the previous video and here I use the layer name NDVI stats which will be a copy of the parcels layer but then with the statistics added to it. Then I run and this is the result. Let's have a look at the attribute table. There we see now nicely the different NDVI statistics for each parcel. We can also style that so I use a graduated color and I choose there one of the statistics. Let's have a look at the mean and here I'm going to use let's use a green color ramp to make it easy. Choose classify and the more darker the green and higher the mean NDVI value in that parcel. You can also do that for the other statistics. Maybe you want to see the maximum per parcel. Just click classify to reapply it. Let's look back at mean and here you can also change how we define the classes. You can also manually edit the classes and you can also change the amount of classes that you want to see. So here let's use now natural breaks which gives a different distribution. At the attribute table I want to add now the surface area of each parcel in the perimeter. So I go to the field calculator and I type the name area which should be a decimal number as the output field type and under geometry you can find dollar area which will calculate the surface area in the map units. So in this case that is square meters. Here it's added. Now I repeat this for the perimeter. I go back to the field calculator output field name perimeter decimal number real and under geometry there is a dollar perimeter function and with double click I can edit and with okay it will be calculated. There's the perimeter of each parcel in the data set. It's a bit more intuitive to have the areas in hectares. So I'm going back to the field calculator and output field name area hectares. The type is also decimal number real. I can do it in two ways. I can convert already calculated area field or I go back to the geometry. Let's use that way. Area divided and then to go from square meters to hectometers I go dividing by that thousand. Click okay and now I have the areas of our parcels in hectares. Save the result and this was the video. I hope you've enjoyed it and learned how to download a Sentinel-2 image, calculate NDVI and so on statistics per parcel.