<?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 arcpy set point every 10 cm hight change on line? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcpy-set-point-every-10-cm-hight-change-on-line/m-p/1159241#M64211</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;i've slightly adapted a script of Bera - Stackexchange - &lt;A href="https://gis.stackexchange.com/questions/308705/split-a-line-at-a-specific-elevation" target="_blank"&gt;https://gis.stackexchange.com/questions/308705/split-a-line-at-a-specific-elevation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It should set a point every 10 cm hight change on a line. The script is somehow working but not very efficient, is there a better way to do it? Originally the script was for one best point on a line ... How not to write single bestpoints to fclass? Any ideas?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# erzeugt Punktshape alle x cm Hoehe entlang Linie

import arcpy
import numpy as np

arcpy.env.overwriteOutput = True

arcpy.env.workspace = r"Path\Berechnung_4.gdb"

fc = r'Path_to_FGDB\Gew_Morre' 
inDGM = r"Path_to_FGDB\dgm01m"

step = 1 # 0.1 in script - Change, as small as possible without making the execution time unacceptably long

arcpy.CheckOutExtension("3D")

Gewaesser_3D = "Gewaesser_3D"
arcpy.InterpolateShape_3d(inDGM, fc, Gewaesser_3D)
arcpy.AddSurfaceInformation_3d(Gewaesser_3D, inDGM, "Z_MIN;Z_MAX", "BILINEAR")

arcpy.CheckInExtension("3D")

with arcpy.da.SearchCursor(Gewaesser_3D,['SHAPE@','Z_MIN','Z_MAX']) as cursor:
    for row in cursor:
        print("valueMin = {} and valueMAx = {}".format(row[1], row[2]))
        arr = np.arange(row[1], row[2], 0.1) # hier Hoehenstufen definieren!
        print(arr)
  
        for r in arr:        

            geom = row[0]
            points = []
            position = 0
            while position &amp;lt; geom.length:
                points.append(geom.positionAlongLine(position))
                position+=step

            bestpoint = min(points, key=lambda x: abs(x.centroid.Z-r))

            strR = round(r, 5)
            print (strR)
            ReplaceRstrR = str(strR).replace(".", "_")
            
            arcpy.CopyFeatures_management(in_features=bestpoint, out_feature_class='bestpoint{}'.format(ReplaceRstrR))

featureclasses = arcpy.ListFeatureClasses("bestpoint*")   

arcpy.Merge_management(featureclasses, "merge_ergebnis_bruchhof_10cm")

&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 30 Mar 2022 07:02:44 GMT</pubDate>
    <dc:creator>JohannesBierer</dc:creator>
    <dc:date>2022-03-30T07:02:44Z</dc:date>
    <item>
      <title>arcpy set point every 10 cm hight change on line?</title>
      <link>https://community.esri.com/t5/python-questions/arcpy-set-point-every-10-cm-hight-change-on-line/m-p/1159241#M64211</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;i've slightly adapted a script of Bera - Stackexchange - &lt;A href="https://gis.stackexchange.com/questions/308705/split-a-line-at-a-specific-elevation" target="_blank"&gt;https://gis.stackexchange.com/questions/308705/split-a-line-at-a-specific-elevation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It should set a point every 10 cm hight change on a line. The script is somehow working but not very efficient, is there a better way to do it? Originally the script was for one best point on a line ... How not to write single bestpoints to fclass? Any ideas?&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# erzeugt Punktshape alle x cm Hoehe entlang Linie

import arcpy
import numpy as np

arcpy.env.overwriteOutput = True

arcpy.env.workspace = r"Path\Berechnung_4.gdb"

fc = r'Path_to_FGDB\Gew_Morre' 
inDGM = r"Path_to_FGDB\dgm01m"

step = 1 # 0.1 in script - Change, as small as possible without making the execution time unacceptably long

arcpy.CheckOutExtension("3D")

Gewaesser_3D = "Gewaesser_3D"
arcpy.InterpolateShape_3d(inDGM, fc, Gewaesser_3D)
arcpy.AddSurfaceInformation_3d(Gewaesser_3D, inDGM, "Z_MIN;Z_MAX", "BILINEAR")

arcpy.CheckInExtension("3D")

with arcpy.da.SearchCursor(Gewaesser_3D,['SHAPE@','Z_MIN','Z_MAX']) as cursor:
    for row in cursor:
        print("valueMin = {} and valueMAx = {}".format(row[1], row[2]))
        arr = np.arange(row[1], row[2], 0.1) # hier Hoehenstufen definieren!
        print(arr)
  
        for r in arr:        

            geom = row[0]
            points = []
            position = 0
            while position &amp;lt; geom.length:
                points.append(geom.positionAlongLine(position))
                position+=step

            bestpoint = min(points, key=lambda x: abs(x.centroid.Z-r))

            strR = round(r, 5)
            print (strR)
            ReplaceRstrR = str(strR).replace(".", "_")
            
            arcpy.CopyFeatures_management(in_features=bestpoint, out_feature_class='bestpoint{}'.format(ReplaceRstrR))

featureclasses = arcpy.ListFeatureClasses("bestpoint*")   

arcpy.Merge_management(featureclasses, "merge_ergebnis_bruchhof_10cm")

&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 07:02:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcpy-set-point-every-10-cm-hight-change-on-line/m-p/1159241#M64211</guid>
      <dc:creator>JohannesBierer</dc:creator>
      <dc:date>2022-03-30T07:02:44Z</dc:date>
    </item>
  </channel>
</rss>

