<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Create Linear transformation tool for raster using ArcPy in ArcMap Questions</title>
    <link>https://community.esri.com/t5/arcmap-questions/create-linear-transformation-tool-for-raster-using/m-p/1004442#M1616</link>
    <description>&lt;P&gt;Is there a rationale behind making a tool from an existing tool (and perhaps limiting its functionality)?&lt;/P&gt;</description>
    <pubDate>Tue, 24 Nov 2020 20:47:45 GMT</pubDate>
    <dc:creator>DavidPike</dc:creator>
    <dc:date>2020-11-24T20:47:45Z</dc:date>
    <item>
      <title>Create Linear transformation tool for raster using ArcPy</title>
      <link>https://community.esri.com/t5/arcmap-questions/create-linear-transformation-tool-for-raster-using/m-p/1004288#M1614</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;So i want to create&amp;nbsp; a tool using Python code values in zero range(Ex:My case 3 to 5),&amp;nbsp;&amp;nbsp;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. &lt;SPAN&gt;&amp;nbsp;I am a beginner and am relatively new to Python, so please excuse me if I sound a bit dumb &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;arcpy&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;os&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;sys&lt;BR /&gt;&lt;SPAN&gt;from &lt;/SPAN&gt;arcpy &lt;SPAN&gt;import &lt;/SPAN&gt;env&lt;BR /&gt;&lt;SPAN&gt;from &lt;/SPAN&gt;arcpy.sa &lt;SPAN&gt;import &lt;/SPAN&gt;*&lt;BR /&gt;arcpy.CheckOutExtension(&lt;SPAN&gt;"Spatial"&lt;/SPAN&gt;)&lt;BR /&gt;env.workspace = &lt;SPAN&gt;r"H:\Test\Test1"&lt;BR /&gt;&lt;/SPAN&gt;arcpy.env.cellSize = &lt;SPAN&gt;100&lt;BR /&gt;&lt;/SPAN&gt;Input = arcpy.GetParameterAsText(&lt;SPAN&gt;0&lt;/SPAN&gt;)&lt;BR /&gt;folder = arcpy.GetParameterAsText(&lt;SPAN&gt;1&lt;/SPAN&gt;)&lt;BR /&gt;raster = arcpy.GetParameterAsText(&lt;SPAN&gt;2&lt;/SPAN&gt;)&lt;BR /&gt;arcpy.AddMessage(&lt;SPAN&gt;"Folder: {}"&lt;/SPAN&gt;.format(folder))&lt;BR /&gt;arcpy.AddMessage(&lt;SPAN&gt;"Raster: {}"&lt;/SPAN&gt;.format(raster))&lt;BR /&gt;save_raster = os.path.join(folder, raster)&lt;BR /&gt;arcpy.AddMessage(&lt;SPAN&gt;"Save Location: {}"&lt;/SPAN&gt;.format(save_raster))&lt;BR /&gt;output = RescaleByFunction(&lt;SPAN&gt;"Elevation"&lt;/SPAN&gt;, TfLinear(Minimum, Maximum, &lt;SPAN&gt;"#"&lt;/SPAN&gt;, &lt;SPAN&gt;"#"&lt;/SPAN&gt;, &lt;SPAN&gt;"#"&lt;/SPAN&gt;, &lt;SPAN&gt;"#"&lt;/SPAN&gt;), &lt;SPAN&gt;0&lt;/SPAN&gt;, &lt;SPAN&gt;1&lt;/SPAN&gt;)&lt;BR /&gt;output.save(save_raster)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Thank you:)&lt;/P&gt;</description>
      <pubDate>Tue, 24 Nov 2020 15:44:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/create-linear-transformation-tool-for-raster-using/m-p/1004288#M1614</guid>
      <dc:creator>Deepa</dc:creator>
      <dc:date>2020-11-24T15:44:49Z</dc:date>
    </item>
    <item>
      <title>Re: Create Linear transformation tool for raster using ArcPy</title>
      <link>https://community.esri.com/t5/arcmap-questions/create-linear-transformation-tool-for-raster-using/m-p/1004442#M1616</link>
      <description>&lt;P&gt;Is there a rationale behind making a tool from an existing tool (and perhaps limiting its functionality)?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Nov 2020 20:47:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/create-linear-transformation-tool-for-raster-using/m-p/1004442#M1616</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-11-24T20:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: Create Linear transformation tool for raster using ArcPy</title>
      <link>https://community.esri.com/t5/arcmap-questions/create-linear-transformation-tool-for-raster-using/m-p/1004468#M1617</link>
      <description>&lt;P&gt;Hi David,&lt;/P&gt;&lt;P&gt;Thanks a lot&amp;nbsp; for the reply. The aim is to make the same tool a bit modified and in line with the terminologies that we use in the assignment. Example, i would like to write it as controlpoint1 = 3, controlpoint2 = 5, controlpoint3 = 7 and controlpoint4 = 8.8 for the example and would like to have just the linear trasformation. How could i add the control points in the code to create a simpler version of the same tool in ArcMap?&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;os&lt;BR /&gt;&lt;SPAN&gt;import &lt;/SPAN&gt;sys&lt;BR /&gt;&lt;SPAN&gt;from &lt;/SPAN&gt;arcpy &lt;SPAN&gt;import &lt;/SPAN&gt;env&lt;BR /&gt;&lt;SPAN&gt;from &lt;/SPAN&gt;arcpy.sa &lt;SPAN&gt;import &lt;/SPAN&gt;*&lt;BR /&gt;arcpy.CheckOutExtension(&lt;SPAN&gt;"Spatial"&lt;/SPAN&gt;)&lt;BR /&gt;env.workspace = &lt;SPAN&gt;r"H:\Test"&lt;BR /&gt;&lt;/SPAN&gt;arcpy.env.cellSize = &lt;SPAN&gt;100&lt;BR /&gt;&lt;/SPAN&gt;inRaster = &lt;SPAN&gt;"elevation"&lt;BR /&gt;&lt;/SPAN&gt;Input = arcpy.GetParameterAsText(&lt;SPAN&gt;0&lt;/SPAN&gt;)&lt;BR /&gt;folder = arcpy.GetParameterAsText(&lt;SPAN&gt;1&lt;/SPAN&gt;)&lt;BR /&gt;raster = arcpy.GetParameterAsText(&lt;SPAN&gt;2&lt;/SPAN&gt;)&lt;BR /&gt;ControlPoint1 = arcpy.GetParameterAsText(&lt;SPAN&gt;3&lt;/SPAN&gt;)&lt;BR /&gt;ControlPoint2 = arcpy.GetParameterAsText(&lt;SPAN&gt;4&lt;/SPAN&gt;)&lt;BR /&gt;ControlPoint3 = arcpy.GetParameterAsText(&lt;SPAN&gt;5&lt;/SPAN&gt;)&lt;BR /&gt;ControlPoint4 = arcpy.GetParameterAsText(&lt;SPAN&gt;6&lt;/SPAN&gt;)&lt;BR /&gt;arcpy.AddMessage(&lt;SPAN&gt;"Folder: {}"&lt;/SPAN&gt;.format(folder))&lt;BR /&gt;arcpy.AddMessage(&lt;SPAN&gt;"Raster: {}"&lt;/SPAN&gt;.format(raster))&lt;BR /&gt;save_raster = os.path.join(folder, raster)&lt;BR /&gt;arcpy.AddMessage(&lt;SPAN&gt;"Save Location: {}"&lt;/SPAN&gt;.format(save_raster))&lt;BR /&gt;minimum = ControlPoint2&lt;BR /&gt;maximum = ControlPoint3&lt;BR /&gt;lowerthresh = ControlPoint1&lt;BR /&gt;valbelowthresh = &lt;SPAN&gt;0&lt;BR /&gt;&lt;/SPAN&gt;upperthresh = ControlPoint4&lt;BR /&gt;valabovethresh = &lt;SPAN&gt;1&lt;BR /&gt;&lt;/SPAN&gt;myTfFunction = TfLinear(minimum, maximum, lowerthresh, valbelowthresh, upperthresh, valabovethresh)&lt;BR /&gt;fromscale = &lt;SPAN&gt;0&lt;BR /&gt;&lt;/SPAN&gt;toscale = &lt;SPAN&gt;1&lt;BR /&gt;&lt;/SPAN&gt;outRescale = RescaleByFunction(inRaster, myTfFunction, fromscale, toscale)&lt;BR /&gt;output.save(save_raster)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Nov 2020 21:45:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/create-linear-transformation-tool-for-raster-using/m-p/1004468#M1617</guid>
      <dc:creator>Deepa</dc:creator>
      <dc:date>2020-11-24T21:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create Linear transformation tool for raster using ArcPy</title>
      <link>https://community.esri.com/t5/arcmap-questions/create-linear-transformation-tool-for-raster-using/m-p/1004483#M1619</link>
      <description>&lt;P&gt;without delving into the rescale function I'd say it looks ok. Maybe pass the controlpoints as floats:&lt;/P&gt;&lt;P&gt;e.g.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ControlPoint1 = float(arcpy.GetParameterAsText(&lt;SPAN&gt;3&lt;/SPAN&gt;))&lt;/PRE&gt;&lt;P&gt;or just arcpy.GetParameter()&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm no expert programmer, but I'd stop renaming variables for no reason, e.g. just call&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;minimum = arcpy.GetParameterAsText(&lt;SPAN&gt;4&lt;/SPAN&gt;)&lt;/PRE&gt;&lt;P&gt;and so on.&amp;nbsp; It seems needlessly confusing otherwise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a specific part it's falling over on?&amp;nbsp; Do you know how to assign the parameters in the script tool itself?&lt;/P&gt;</description>
      <pubDate>Tue, 24 Nov 2020 22:10:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/create-linear-transformation-tool-for-raster-using/m-p/1004483#M1619</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2020-11-24T22:10:46Z</dc:date>
    </item>
    <item>
      <title>Re: Create Linear transformation tool for raster using ArcPy</title>
      <link>https://community.esri.com/t5/arcmap-questions/create-linear-transformation-tool-for-raster-using/m-p/1005455#M1645</link>
      <description>&lt;P&gt;Yes the tool has worked. Thank you so much &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 11:14:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcmap-questions/create-linear-transformation-tool-for-raster-using/m-p/1005455#M1645</guid>
      <dc:creator>Deepa</dc:creator>
      <dc:date>2020-11-30T11:14:19Z</dc:date>
    </item>
  </channel>
</rss>

