<?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 Standardising rasters in arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/standardising-rasters-in-arcpy/m-p/1058014#M61123</link>
    <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to to standardise some rasters using a loop and following equation&lt;/P&gt;&lt;P&gt;X1= (X - X.min())/(X.max()-X.min())&lt;/P&gt;&lt;P&gt;where X is the original dataset, and X1 the new standardized dataset, which has a minimum value of 0 and a maximum value of 1.&lt;/P&gt;&lt;P&gt;I was wondering how I would go about doing this? the current code I have is&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for calc in projected_rast:
    print calc
    minLSTresult = arcpy.GetRasterProperties_management(calc, "MINIMUM")
    maxLSTresult = arcpy.GetRasterProperties_management(calc, "MAXIMUM")
    standardised = ((calc - minLSTresult)/(maxLSTresult-minLSTresult))
    standardised.save()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;were projected_rast is a list of strings to my rasters&lt;/P&gt;</description>
    <pubDate>Fri, 14 May 2021 13:15:28 GMT</pubDate>
    <dc:creator>DanielFuller</dc:creator>
    <dc:date>2021-05-14T13:15:28Z</dc:date>
    <item>
      <title>Standardising rasters in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/standardising-rasters-in-arcpy/m-p/1058014#M61123</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to to standardise some rasters using a loop and following equation&lt;/P&gt;&lt;P&gt;X1= (X - X.min())/(X.max()-X.min())&lt;/P&gt;&lt;P&gt;where X is the original dataset, and X1 the new standardized dataset, which has a minimum value of 0 and a maximum value of 1.&lt;/P&gt;&lt;P&gt;I was wondering how I would go about doing this? the current code I have is&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for calc in projected_rast:
    print calc
    minLSTresult = arcpy.GetRasterProperties_management(calc, "MINIMUM")
    maxLSTresult = arcpy.GetRasterProperties_management(calc, "MAXIMUM")
    standardised = ((calc - minLSTresult)/(maxLSTresult-minLSTresult))
    standardised.save()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;were projected_rast is a list of strings to my rasters&lt;/P&gt;</description>
      <pubDate>Fri, 14 May 2021 13:15:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/standardising-rasters-in-arcpy/m-p/1058014#M61123</guid>
      <dc:creator>DanielFuller</dc:creator>
      <dc:date>2021-05-14T13:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: Standardising rasters in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/standardising-rasters-in-arcpy/m-p/1058240#M61132</link>
      <description>&lt;P&gt;What does it yield?&lt;/P&gt;&lt;P&gt;Are you using ArcMap? (your print statement suggests python 2.7)&lt;/P&gt;&lt;P&gt;Do you have any null areas/values?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Of course you could use RasterToNumPyArray and use numpy to do the work quickly.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import numpy as np
a = np.arange(0, 12.).reshape(4, 3)
a
array([[ 0.,  1.,  2.],
       [ 3.,  4.,  5.],
       [ 6.,  7.,  8.],
       [ 9., 10., 11.]])

a_min = np.nanmin(a)
a_max = np.nanmax(a)
a_stand = (a - a_min) / (a_max - a_min)

a_stand
array([[0.        , 0.09090909, 0.18181818],
       [0.27272727, 0.36363636, 0.45454545],
       [0.54545455, 0.63636364, 0.72727273],
       [0.81818182, 0.90909091, 1.        ]])&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 14 May 2021 22:58:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/standardising-rasters-in-arcpy/m-p/1058240#M61132</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-05-14T22:58:16Z</dc:date>
    </item>
    <item>
      <title>Re: Standardising rasters in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/standardising-rasters-in-arcpy/m-p/1058268#M61135</link>
      <description>&lt;P&gt;a &lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/classes/raster-object.htm#:~:text=Boolean-,maximum,-(Read" target="_blank" rel="noopener"&gt;&lt;FONT face="courier new,courier"&gt;Raster&lt;/FONT&gt;&lt;/A&gt; object has &lt;FONT face="courier new,courier"&gt;maximum&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;minimum&lt;/FONT&gt; properties (if statistics have been calculated).&lt;/P&gt;&lt;LI-CODE lang="python"&gt;for calc in projected_rast:
    print(calc)
    raster = arcpy.Raster(calc)
    minLSTresult = raster.minimum
    maxLSTresult = raster.maximum
    standardised = ((raster - minLSTresult)/(maxLSTresult-minLSTresult))
    standardised.save()&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 15 May 2021 00:54:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/standardising-rasters-in-arcpy/m-p/1058268#M61135</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2021-05-15T00:54:03Z</dc:date>
    </item>
    <item>
      <title>Re: Standardising rasters in arcpy</title>
      <link>https://community.esri.com/t5/python-questions/standardising-rasters-in-arcpy/m-p/1058303#M61137</link>
      <description>&lt;P&gt;Worked perfectly &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 15 May 2021 21:43:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/standardising-rasters-in-arcpy/m-p/1058303#M61137</guid>
      <dc:creator>DanielFuller</dc:creator>
      <dc:date>2021-05-15T21:43:10Z</dc:date>
    </item>
  </channel>
</rss>

