I am trying to convert a raster file with values ranging from 3.2 to 8.8 into a linear scale from 0 to 1. The conditions that i want to apply in the transformation are as follows: 3 to 5 gets 0, 5 to 7 Linear variation from o to 1 and gets values based on straight line equation y = (slope)x + c, And greater than 7 gets 1. This is an example and this may vary with others preferences.
So i want to create a tool using Python code values in zero range(Ex:My case 3 to 5), Linearly varying values from o to 1 range(Ex:My case 5 to 7),values in 1 range(Ex:My case greater than 7).How is it possible to create linear transformation as a tool in ArcGIS using python code where i can input those conditions mentioned above as parameters in the tool? I would like to send this tool to other users and so their conditions may vary based on it. What changes to be made in this code to make it work with the conditions. I am a beginner and am relatively new to Python, so please excuse me if I sound a bit dumb 🙂
import arcpy
import os
import sys
from arcpy import env
from arcpy.sa import *
arcpy.CheckOutExtension("Spatial")
env.workspace = r"H:\Test\Test1"
arcpy.env.cellSize = 100
Input = arcpy.GetParameterAsText(0)
folder = arcpy.GetParameterAsText(1)
raster = arcpy.GetParameterAsText(2)
arcpy.AddMessage("Folder: {}".format(folder))
arcpy.AddMessage("Raster: {}".format(raster))
save_raster = os.path.join(folder, raster)
arcpy.AddMessage("Save Location: {}".format(save_raster))
output = RescaleByFunction("Elevation", TfLinear(Minimum, Maximum, "#", "#", "#", "#"), 0, 1)
output.save(save_raster)
Thank you:)