<?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 to determine distance in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/arcpy-to-determine-distance/m-p/333420#M2127</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Eons ago, our group would identify points for registration forms using a USGS quad broken into 9 segments.&amp;nbsp; From the top right of one of the segments, it would basically say 9,645 feet left, 7,123 feet down (or something like that).&amp;nbsp; I've been tasked with converting these to true lat/lon in decimal degrees.&amp;nbsp; I can usually figure out a python way of doing something like this, but working with the geometry and unit difference is really proving to be difficult for me.&amp;nbsp; Could anyone please help or lead me in the right direction?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to write a tool that the user can enter in the original x,y distance in feet.&amp;nbsp; The tool would then; from the top right corner of the quad; plot the point based on the difference (basically, just slope from the origin) and then return what the true lat/lon would be in decimal degrees.&amp;nbsp; So in essence, I'm taking an origin of perhaps 41.111, -75.111.&amp;nbsp; User then puts in 2000 feet across, 1500 feet down.&amp;nbsp; Python takes care of the slope and plots the point based on the values.&amp;nbsp; It then returns the new lat/lon; say 41.002, -75.189.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is what I had just from using the ArcGIS help snippets.&amp;nbsp; I was using the arcpy window to observe the process, but once it's working, I'd move it to a stand-alone script.&amp;nbsp; The part in the code after the triple hash is where I'm having trouble.&amp;nbsp; I try and grab the top right vertex point of the selected quad/sector polygon and get it's x,y to use as the origin.&amp;nbsp; I sort of have it, but can't seem to figure out how to isolate it to use in the math.&amp;nbsp; Even then, I'm not sure the python functions that I need to use to then get a new location based on the slope in feet from the origin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I apologize for not having the below formatted. I don't use this often, so I don't know how to get it wrapped into the python code block.&amp;nbsp; I'm sure glad ESRI makes it easy to use emoticons in here though because that certainly makes things easier!(not sure which one is the sarcasm one)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcpy import mapping&lt;BR /&gt;import os&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mxd = mapping.MapDocument("CURRENT")&lt;BR /&gt;FC = mapping.ListLayers(mxd)[2] #this is the quad cut into 9 sectors and is identified on the registration forms&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# the following 2 variables would be populated by the user, but for now are dummy values for testing&lt;/P&gt;&lt;P&gt;Quad = "'" + "TAMAQUA" + "'"&lt;/P&gt;&lt;P&gt;Sector = 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# find the record in the feature class based on above&lt;/P&gt;&lt;P&gt;arcpy.SelectLayerByAttribute_management(FC,"NEW_SELECTION","[QUAD_NAME] = " + Quad + "AND [SECT_NUM] =" + str(Sector))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;### this is where it gets tricky...&lt;/P&gt;&lt;P&gt;for row in arcpy.da.SearchCursor(FC, ["OID@", "SHAPE@"]):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Feature {0}:".format(row[0])&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partnum = 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for part in row[1]:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Part {0}:".format(partnum)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for pnt in part:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if pnt:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "{0}, {1}".format(pnt.X, pnt.Y)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Interior Ring"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partnum += 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The results I get are:&lt;/P&gt;&lt;P&gt;Feature 3930:&lt;BR /&gt;Part 0:&lt;BR /&gt;-75.916347055, 40.875087773&lt;BR /&gt;-75.874642422, 40.875088341&lt;BR /&gt;-75.874642491, 40.833417869&lt;BR /&gt;-75.916347289, 40.833417228&lt;BR /&gt;-75.916347055, 40.875087773&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Nov 2016 14:58:03 GMT</pubDate>
    <dc:creator>StephenKruzik1</dc:creator>
    <dc:date>2016-11-30T14:58:03Z</dc:date>
    <item>
      <title>Arcpy to determine distance</title>
      <link>https://community.esri.com/t5/developers-questions/arcpy-to-determine-distance/m-p/333420#M2127</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Eons ago, our group would identify points for registration forms using a USGS quad broken into 9 segments.&amp;nbsp; From the top right of one of the segments, it would basically say 9,645 feet left, 7,123 feet down (or something like that).&amp;nbsp; I've been tasked with converting these to true lat/lon in decimal degrees.&amp;nbsp; I can usually figure out a python way of doing something like this, but working with the geometry and unit difference is really proving to be difficult for me.&amp;nbsp; Could anyone please help or lead me in the right direction?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to write a tool that the user can enter in the original x,y distance in feet.&amp;nbsp; The tool would then; from the top right corner of the quad; plot the point based on the difference (basically, just slope from the origin) and then return what the true lat/lon would be in decimal degrees.&amp;nbsp; So in essence, I'm taking an origin of perhaps 41.111, -75.111.&amp;nbsp; User then puts in 2000 feet across, 1500 feet down.&amp;nbsp; Python takes care of the slope and plots the point based on the values.&amp;nbsp; It then returns the new lat/lon; say 41.002, -75.189.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;here is what I had just from using the ArcGIS help snippets.&amp;nbsp; I was using the arcpy window to observe the process, but once it's working, I'd move it to a stand-alone script.&amp;nbsp; The part in the code after the triple hash is where I'm having trouble.&amp;nbsp; I try and grab the top right vertex point of the selected quad/sector polygon and get it's x,y to use as the origin.&amp;nbsp; I sort of have it, but can't seem to figure out how to isolate it to use in the math.&amp;nbsp; Even then, I'm not sure the python functions that I need to use to then get a new location based on the slope in feet from the origin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I apologize for not having the below formatted. I don't use this often, so I don't know how to get it wrapped into the python code block.&amp;nbsp; I'm sure glad ESRI makes it easy to use emoticons in here though because that certainly makes things easier!(not sure which one is the sarcasm one)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;from arcpy import mapping&lt;BR /&gt;import os&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mxd = mapping.MapDocument("CURRENT")&lt;BR /&gt;FC = mapping.ListLayers(mxd)[2] #this is the quad cut into 9 sectors and is identified on the registration forms&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# the following 2 variables would be populated by the user, but for now are dummy values for testing&lt;/P&gt;&lt;P&gt;Quad = "'" + "TAMAQUA" + "'"&lt;/P&gt;&lt;P&gt;Sector = 3&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;# find the record in the feature class based on above&lt;/P&gt;&lt;P&gt;arcpy.SelectLayerByAttribute_management(FC,"NEW_SELECTION","[QUAD_NAME] = " + Quad + "AND [SECT_NUM] =" + str(Sector))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;### this is where it gets tricky...&lt;/P&gt;&lt;P&gt;for row in arcpy.da.SearchCursor(FC, ["OID@", "SHAPE@"]):&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Feature {0}:".format(row[0])&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partnum = 0&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for part in row[1]:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Part {0}:".format(partnum)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for pnt in part:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if pnt:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "{0}, {1}".format(pnt.X, pnt.Y)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Interior Ring"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; partnum += 1&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The results I get are:&lt;/P&gt;&lt;P&gt;Feature 3930:&lt;BR /&gt;Part 0:&lt;BR /&gt;-75.916347055, 40.875087773&lt;BR /&gt;-75.874642422, 40.875088341&lt;BR /&gt;-75.874642491, 40.833417869&lt;BR /&gt;-75.916347289, 40.833417228&lt;BR /&gt;-75.916347055, 40.875087773&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Nov 2016 14:58:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/arcpy-to-determine-distance/m-p/333420#M2127</guid>
      <dc:creator>StephenKruzik1</dc:creator>
      <dc:date>2016-11-30T14:58:03Z</dc:date>
    </item>
  </channel>
</rss>

