<?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 ExtractMultiValuesToPoints exhbits strange behavior in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/extractmultivaluestopoints-exhbits-strange/m-p/1202817#M58616</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am trying to understand the behavior of ExtractMultiValuesToPoints when incorporated into an Arcgis tool.&lt;/P&gt;&lt;P&gt;I have used the function in an Arcpy standalone script, and it works just fine. However, after incorporating into a python tool, the stars have to be aligned just right for it to work. Included is a tool that I have created to extract values from a multiband raster into a new shapefile.&lt;/P&gt;&lt;P&gt;The issues are (1) I have to rename the bands because the tool generates new names not related to the raster bands, (2) if the shapefile is linked to the tool from a GIS workspace, the names aren't carried over, (3) rasters cannot be linked to from a GIS workspace and (4) ExtractMultiValuesToPoints has no option to preserve the original file (as far as I can tell). These are really just minor annoyances, so am wondering if I am somehow doing it wrong. Thanks for any information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;class Combine_labels_features(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "07 Combine labels and features"
        self.description = "This tool combines the labels point shapefile (generated and QAQC'd) with the appropriate features file"
        self.canRunInBackground = False

    def getParameterInfo(self):
        """Define parameter definitions"""
        labels = arcpy.Parameter(
            displayName="labels file",
            name="labels",
            datatype="GPFeatureLayer",  
            parameterType="Required",
            direction="Input")
        labels.filter.list = ["Point"] 

        features = arcpy.Parameter(
            displayName="features (raster)",
            name="features",
            datatype= u'GPRasterLayer',  
            parameterType="Required",
            direction="Input")
        
        outfile = arcpy.Parameter(
            displayName="outfile",
            name="outFile",
            datatype="DEType",
            parameterType="Required",
            direction="Output")

        params = [labels,features,outfile]
        return params

    def isLicensed(self):
        """Set whether tool is licensed to execute."""
        return True

    def updateParameters(self, parameters):
        """Modify the values and properties of parameters before internal
        validation is performed.  This method is called whenever a parameter
        has been changed."""
        return

    def updateMessages(self, parameters):
        """Modify the messages created by internal validation for each tool
        parameter.  This method is called after internal validation."""
        return

    def execute(self, parameters, messages):
        """The source code of the tool."""
        labels = parameters[0].valueAsText
        infile = parameters[1].valueAsText
        outfile = parameters[2].valueAsText

        features = Raster(infile)

        rasters = [] ### holder for raster predictors
        nams = features.bandNames
        names = ["B_" + str(i+1) for i in range(0,len(nams))]

        for i in range(0,len(nams)):
            print(nams[i])
            tmplist = [infile + "\\" + nams[i],names[i]]
            rasters.append(tmplist)

        origNames = [field.name for field in arcpy.ListFields(labels)]
        
        arcpy.sa.ExtractMultiValuesToPoints(labels,infile,"BILINEAR")
        tmpfile = os.path.basename(tempfile.TemporaryFile().name)
        arcpy.management.CopyFeatures(labels,tmpfile,'', None, None, None)

        badNames = [field.name for field in arcpy.ListFields(tmpfile)]
        badNames = [x for x in badNames if x not in origNames]
        badNames.remove("OBJECTID")

        BandKey = {badNames[i]:nams[i] for i in range(len(badNames))} 

        for key, value in BandKey.items():
            print(key)
            print(value)
            arcpy.AlterField_management(tmpfile, key,value)

        ## add directly to initial labels. Should make copy if you want to preserve.
        ## ExtractMultiValuesToPoints is not behaving as it should. In Arcpy, the names from
        ## the original rasters carries through. Does not happen in the tool. Not sure why,
        arcpy.management.CopyFeatures(tmpfile,outfile,'', None, None, None)
        arcpy.Delete_management(tmpfile)
                
        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Aug 2022 14:08:30 GMT</pubDate>
    <dc:creator>WadeWall</dc:creator>
    <dc:date>2022-08-15T14:08:30Z</dc:date>
    <item>
      <title>ExtractMultiValuesToPoints exhbits strange behavior</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/extractmultivaluestopoints-exhbits-strange/m-p/1202817#M58616</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am trying to understand the behavior of ExtractMultiValuesToPoints when incorporated into an Arcgis tool.&lt;/P&gt;&lt;P&gt;I have used the function in an Arcpy standalone script, and it works just fine. However, after incorporating into a python tool, the stars have to be aligned just right for it to work. Included is a tool that I have created to extract values from a multiband raster into a new shapefile.&lt;/P&gt;&lt;P&gt;The issues are (1) I have to rename the bands because the tool generates new names not related to the raster bands, (2) if the shapefile is linked to the tool from a GIS workspace, the names aren't carried over, (3) rasters cannot be linked to from a GIS workspace and (4) ExtractMultiValuesToPoints has no option to preserve the original file (as far as I can tell). These are really just minor annoyances, so am wondering if I am somehow doing it wrong. Thanks for any information.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;class Combine_labels_features(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "07 Combine labels and features"
        self.description = "This tool combines the labels point shapefile (generated and QAQC'd) with the appropriate features file"
        self.canRunInBackground = False

    def getParameterInfo(self):
        """Define parameter definitions"""
        labels = arcpy.Parameter(
            displayName="labels file",
            name="labels",
            datatype="GPFeatureLayer",  
            parameterType="Required",
            direction="Input")
        labels.filter.list = ["Point"] 

        features = arcpy.Parameter(
            displayName="features (raster)",
            name="features",
            datatype= u'GPRasterLayer',  
            parameterType="Required",
            direction="Input")
        
        outfile = arcpy.Parameter(
            displayName="outfile",
            name="outFile",
            datatype="DEType",
            parameterType="Required",
            direction="Output")

        params = [labels,features,outfile]
        return params

    def isLicensed(self):
        """Set whether tool is licensed to execute."""
        return True

    def updateParameters(self, parameters):
        """Modify the values and properties of parameters before internal
        validation is performed.  This method is called whenever a parameter
        has been changed."""
        return

    def updateMessages(self, parameters):
        """Modify the messages created by internal validation for each tool
        parameter.  This method is called after internal validation."""
        return

    def execute(self, parameters, messages):
        """The source code of the tool."""
        labels = parameters[0].valueAsText
        infile = parameters[1].valueAsText
        outfile = parameters[2].valueAsText

        features = Raster(infile)

        rasters = [] ### holder for raster predictors
        nams = features.bandNames
        names = ["B_" + str(i+1) for i in range(0,len(nams))]

        for i in range(0,len(nams)):
            print(nams[i])
            tmplist = [infile + "\\" + nams[i],names[i]]
            rasters.append(tmplist)

        origNames = [field.name for field in arcpy.ListFields(labels)]
        
        arcpy.sa.ExtractMultiValuesToPoints(labels,infile,"BILINEAR")
        tmpfile = os.path.basename(tempfile.TemporaryFile().name)
        arcpy.management.CopyFeatures(labels,tmpfile,'', None, None, None)

        badNames = [field.name for field in arcpy.ListFields(tmpfile)]
        badNames = [x for x in badNames if x not in origNames]
        badNames.remove("OBJECTID")

        BandKey = {badNames[i]:nams[i] for i in range(len(badNames))} 

        for key, value in BandKey.items():
            print(key)
            print(value)
            arcpy.AlterField_management(tmpfile, key,value)

        ## add directly to initial labels. Should make copy if you want to preserve.
        ## ExtractMultiValuesToPoints is not behaving as it should. In Arcpy, the names from
        ## the original rasters carries through. Does not happen in the tool. Not sure why,
        arcpy.management.CopyFeatures(tmpfile,outfile,'', None, None, None)
        arcpy.Delete_management(tmpfile)
                
        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 14:08:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/extractmultivaluestopoints-exhbits-strange/m-p/1202817#M58616</guid>
      <dc:creator>WadeWall</dc:creator>
      <dc:date>2022-08-15T14:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: ExtractMultiValuesToPoints exhbits strange behavior</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/extractmultivaluestopoints-exhbits-strange/m-p/1203070#M58654</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/spatial-analyst/extract-multi-values-to-points.htm" target="_blank"&gt;Extract Multi Values to Points (Spatial Analyst)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;regarding (4)&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;This tool modifies the input point features and may change its internal feature ID, which may be named ObjectID, FID, or OID. It is recommended that you include a unique ID field in the attribute table before performing the analysis.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;OBJECTID is mentioned as well as shapefile, did you mean to include FID and OID for removal as well?&lt;/P&gt;</description>
      <pubDate>Mon, 15 Aug 2022 22:40:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/extractmultivaluestopoints-exhbits-strange/m-p/1203070#M58654</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-08-15T22:40:28Z</dc:date>
    </item>
    <item>
      <title>Re: ExtractMultiValuesToPoints exhbits strange behavior</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/extractmultivaluestopoints-exhbits-strange/m-p/1203239#M58679</link>
      <description>&lt;P&gt;For the purposes of the tool, ObjectID is not important, but I can see that in many cases it would be important.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2022 13:37:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/extractmultivaluestopoints-exhbits-strange/m-p/1203239#M58679</guid>
      <dc:creator>WadeWall</dc:creator>
      <dc:date>2022-08-16T13:37:59Z</dc:date>
    </item>
  </channel>
</rss>

