<?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 Assign Z value from DEM to line ends in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/assign-z-value-from-dem-to-line-ends/m-p/738698#M57143</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;PLEASE HELP URGENT - Is there anyone at all who can help with this?&amp;nbsp; I wrote a script based on the Extract Value To Points tool but it doesn't work properly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a simplified line shapefile and I want to add elevation (z values) from a DEM raster layer to the end points of the lines.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have written the following code (its user input) but when I run it as a tool it reports that it has run successfully but it doesn't actually output the point shape file with the z values!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any hints or even alternative suggestions would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;code -&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# script to extract raster values to point shapefile&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# adapted by Scott MacDonald Kingston University k0848626 GSM655Programming Asssignment C&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# import system modules&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy.sa import *&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# get user supplied path, layers and fields&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;path = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = path&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# in Feature Layer is Confluence_Pts &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;in_point_features = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# in Raster Layer is DEM&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;in_raster = arcpy.GetParameterAsText(2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# out Feature Class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;out_point_features = arcpy.GetParameterAsText(3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# error trapping measures&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; # check out spatial analyst extension&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; arcpy.CheckOutExtension("Spatial")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; # run the ExractValuesToPoints tool&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; arcpy.ExtractValuesToPoints(in_point_features, in_raster, out_point_features)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; # check in spatial analyst extension&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; arcpy.CheckInExtension("Spatial")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;except:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; print arcpy.GetMessages()&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 09 Jan 2013 18:43:10 GMT</pubDate>
    <dc:creator>ScottMacDonald</dc:creator>
    <dc:date>2013-01-09T18:43:10Z</dc:date>
    <item>
      <title>Assign Z value from DEM to line ends</title>
      <link>https://community.esri.com/t5/python-questions/assign-z-value-from-dem-to-line-ends/m-p/738698#M57143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;PLEASE HELP URGENT - Is there anyone at all who can help with this?&amp;nbsp; I wrote a script based on the Extract Value To Points tool but it doesn't work properly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a simplified line shapefile and I want to add elevation (z values) from a DEM raster layer to the end points of the lines.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have written the following code (its user input) but when I run it as a tool it reports that it has run successfully but it doesn't actually output the point shape file with the z values!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any hints or even alternative suggestions would be appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;code -&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# script to extract raster values to point shapefile&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# adapted by Scott MacDonald Kingston University k0848626 GSM655Programming Asssignment C&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# import system modules&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy import env&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;from arcpy.sa import *&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# get user supplied path, layers and fields&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;path = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.workspace = path&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# in Feature Layer is Confluence_Pts &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;in_point_features = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# in Raster Layer is DEM&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;in_raster = arcpy.GetParameterAsText(2)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;# out Feature Class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;out_point_features = arcpy.GetParameterAsText(3)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# error trapping measures&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; # check out spatial analyst extension&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; arcpy.CheckOutExtension("Spatial")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; # run the ExractValuesToPoints tool&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; arcpy.ExtractValuesToPoints(in_point_features, in_raster, out_point_features)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; # check in spatial analyst extension&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; arcpy.CheckInExtension("Spatial")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;except:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; print arcpy.GetMessages()&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 09 Jan 2013 18:43:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/assign-z-value-from-dem-to-line-ends/m-p/738698#M57143</guid>
      <dc:creator>ScottMacDonald</dc:creator>
      <dc:date>2013-01-09T18:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: Assign Z value from DEM to line ends</title>
      <link>https://community.esri.com/t5/python-questions/assign-z-value-from-dem-to-line-ends/m-p/738699#M57144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Add surface information in the 3d analyst toolbox will populate your line nodes with z values.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Jan 2013 19:52:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/assign-z-value-from-dem-to-line-ends/m-p/738699#M57144</guid>
      <dc:creator>GerryGabrisch</dc:creator>
      <dc:date>2013-01-10T19:52:19Z</dc:date>
    </item>
    <item>
      <title>Re: Assign Z value from DEM to line ends</title>
      <link>https://community.esri.com/t5/python-questions/assign-z-value-from-dem-to-line-ends/m-p/738700#M57145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;PLEASE HELP URGENT - Is there anyone at all who can help with this?&amp;nbsp; I wrote a script based on the Extract Value To Points tool but it doesn't work properly.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You have incorrect syntax for ExtractValuesToPoints. You need to add the toolbox name after it if you prefix the tool name with arcpy. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm pretty sure your script is failing (the tool is not running). You are getting a python error which is not getting printed by your except block.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/002z/002z0000000q000000.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;good examples in the online help&lt;/A&gt;&lt;SPAN&gt; on how to use python exceptions to capture both kinds of errors and report more helpful messages.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;

# script to extract raster values to point shapefile
# adapted by Scott MacDonald Kingston University k0848626 GSM655Programming Asssignment C

# import system modules
import arcpy
from arcpy import env
from arcpy.sa import *

# get user supplied path, layers and fields
path = arcpy.GetParameterAsText(0)
arcpy.env.workspace = path

# in Feature Layer is Confluence_Pts 
in_point_features = arcpy.GetParameterAsText(1)
# in Raster Layer is DEM
in_raster = arcpy.GetParameterAsText(2)
# out Feature Class
out_point_features = arcpy.GetParameterAsText(3)

# error trapping measures
try:
 # check out spatial analyst extension
 arcpy.CheckOutExtension("Spatial")

 # run the ExractValuesToPoints tool
 arcpy.ExtractValuesToPoints&lt;SPAN style="color:red;"&gt;&lt;STRONG&gt;_sa&lt;/STRONG&gt;&lt;/SPAN&gt;(in_point_features, in_raster, out_point_features)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # because of your "from arcpy.sa import *" above you could perhaps do this too:
 # ExtractValuesToPoints(in_point_features, in_raster, out_point_features)

 # check in spatial analyst extension
 arcpy.CheckInExtension("Spatial")

except &lt;SPAN style="color:red;"&gt;&lt;STRONG&gt;Exception, msg:
 print arcpy.GetMessages()&lt;/STRONG&gt; # ArcGIS tool messages
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;STRONG&gt;print "Python errors:\n",str(msg)&lt;/STRONG&gt; # python errors&lt;/SPAN&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 07:27:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/assign-z-value-from-dem-to-line-ends/m-p/738700#M57145</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2021-12-12T07:27:16Z</dc:date>
    </item>
  </channel>
</rss>

