 Hello, in this video we are going to add our own PCRuster tool to the Processing Toolbox. I assume that you have installed correctly the PCRuster Tools plugin, otherwise check my previous videos. The easy way to create your own tool is to look at previously developed tools, and you can access previously developed PCRuster Tools in the Resource Sharing plugin. Install the Resource Sharing plugin, click the icon and go to Settings and we are going to add the repository that contains the PCRuster user scripts. I'll put the link also in the description of this video. Give the repository a name and copy the URL, don't forget to add .git. Then go to the All Collections tab and there you find the collections in the Resource Sharing repository. Then the one we need now is the PCRuster user script collection. Click Install. Now it has added 9 Processing Scripts to the Processing Toolbox. Here they are. Let's choose an easy one to edit and develop our own script. So click right on Map Average, that's an easy one and then you can edit the script and you see that in the beginning of the script we only import the functions that we need for running this script, the same for the QGIS Core imports. Then we define the class of the algorithm with inputs and outputs, the names, name of the script to which group it belongs, how it shows up for the user, some help text. Then we here define the dialogue and the actual Python magic happens here under the Process Algorithm function or method and that's what we are going to edit and in this example we are going to calculate NDVI based on a red band and a near-infrared band that the user needs to select. So we're going to modify this code. So let's first remove what we don't need, we can later add if we have extra things. We should always use ReadMap to read the roster, set clone to set the clone to the first roster that we loaded, always be checked and then report for writing the result to disk. In this case we'll just do simple algebra so we don't need many other functions. But we do have two rosters so I change this to input red and then another input for the near-infrared and they need to be defined here as strings and output we keep it as this. Then we need to change the name of the class and I call it NDVI algorithm and here at the instance use the same name, here the name in short and then what it shows to the user and we keep the group as it is to end up in the pcraster user scripts and then here we can define the help text. So provide the user some context and it's good practice to define here which inputs are required and define the output, indicate the expected data types. Then we define the dialogue so we have input red that refers to what we have over there and then the string that the user sees. Let's copy this for the near-infrared, let's change the dialogue text for the output and now we can define our script so we have the red band, it reads the input that is defined by the user for the red band. Copy the line and the output roster can be the same but the set clone needs to be set to red, the first roster so it will check that the red and the near-infrared are the same dimensions which is needed for map algebra. Here we define the variable in pcraster format and read the file from disk using the input red properties of the file path and we do the same for the near-infrared and then the line that calculates ndvi and that's the input near-infrared roster minus the input red roster brackets divided by input near-infrared plus input red, you can just copy that and change it in a plus. That's all for our calculations, I remove the lines that we don't need and then we just go to the output and the output file path is then also red from where the user wants to store it from the interface and then we can use report by taking that path and the variable and then it will be saved. Normally I go back here to see what we need to import so for pcraster that's all okay but for QGIS we can remove there something that we don't need. Don't forget to save it under a new name otherwise it will overwrite the existing file and if you save it here under your scripts in the profile folder then you'll find it here in the processing toolbox. So now let's try to run it and we see that it gives an error and you can click view message log to see if it gives you something that you can fix but this error is a bit vague so it's better to then check the script and find the error so the error here is that the class name should be the same as the instance both with lowercase and now it runs so we can now feed it with some data so let's download the data so let's see if we can easily download a sentinel image from the stack API browser plugin you can find it in the plugins manager then I will add this icon you can choose from different connections. Let's see what the Microsoft planetary computer has and it has a lot of different layers for us and there's also sentinel 2 level 2a can filter by date but I also want to select a place so therefore I need to zoom in in the map canvas so let's download it for Florence I'll add open street map here I use the locator bar if you use larger than and then type some location and we'll use the nominate in geocoder to find the location so here is Florence or Firenze go back to the stack API browser and I look for a recent image that's been very dry these days so there must be many cloudless images available so maybe someone the first week of August and for the extent I choose the map canvas extent and then I hit search and it found two images gives the percentage of cloud cover and a preview that all looks great. If I click view assets then I can choose here the bands that I want to download and we need band 4 red at 10 meters and near infrared at 10 meters and here we add them and there we see the two bands then we need to convert them to the PC raster format and we choose scalar as the data type let's save it to disk is the near band they'll take a bit because it's the complete image it's not cut out for this map canvas extent that was just used for the search so it has the full sentinel tile do the same for the red band and now these bands are ready to use in our tool so click on the calculate and DVI tool select the correct bands and save the output so automatically loaded but as you can see it ends up somewhere no island because it does not have a projection PC raster doesn't deal with projections so we need to assign projection and we are going to use the one from the input images it's UTM and if we then zoom to the layer you'll see that it nicely overlaps with open street map and let's find Florence again change the color ramp use something that when it's a positive values it goes into green and here we can compare it now with open street map to see if it matches the green areas and we see that it does so NDVI the higher the value the greener it is in the raster and corresponds with the parks on open street map so in this video you've learned how to develop a processing tool with PC raster scripts and you can share this tool with other users by doing a pull request in the repository that was also used in this video so to do that go to the repository and click on the collections folder there go to the PC raster user scripts processing folder and there you can add your script to locate it go to settings user profiles open active profile folder that opens the folders in your QGIS profile and you'll find your script in the processing folder under scripts and then simply drag it to github that opens the pull request interface there's just a little bug that you need to drag it again to add the file otherwise it's not uploading the file and then you can give a comment to your commit for example the name of the tool that you added and then choose to create a new branch and start a pull request and then click propose changes and then it will start processing that and then it will inform me that somebody did a pull request and after a short check I will add it to the repository and anybody else in the world can download it