<?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 Re: Creating Polylines to track migration in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/creating-polylines-to-track-migration/m-p/760869#M24813</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for this information. I will make x,y tables and see if I can get this to work. I am using arcmap 10.1, and I have not used Python yet. Now I will take a class in how to apply it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rich&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sent from Windows Mail&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 25 Jan 2015 08:09:33 GMT</pubDate>
    <dc:creator>RichardOwens1</dc:creator>
    <dc:date>2015-01-25T08:09:33Z</dc:date>
    <item>
      <title>Creating Polylines to track migration</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/creating-polylines-to-track-migration/m-p/760864#M24808</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;I am a beginner in GIS and would like to create a representation of migration across borders. Can anyone recommend a "how to" resource?&lt;/P&gt;&lt;P&gt;I would like to show the movement from provinces, districts and/or towns.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 07:21:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/creating-polylines-to-track-migration/m-p/760864#M24808</guid>
      <dc:creator>RichardOwens1</dc:creator>
      <dc:date>2015-01-23T07:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Polylines to track migration</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/creating-polylines-to-track-migration/m-p/760865#M24809</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have a table with the X,Y (or lat, lon) of the from and to locations on a single record you can use the &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//0017000000tv000000"&gt;XY To Line (Data Management)&lt;/A&gt; tool. This will create straight lines between the from and to locations. The bad thing about this is that if you have migration between two locations in both directions, it will overlap.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 13:01:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/creating-polylines-to-track-migration/m-p/760865#M24809</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-01-23T13:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Polylines to track migration</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/creating-polylines-to-track-migration/m-p/760866#M24810</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In case you don't want to have straight lines you could do something like this (black lines are the curves created in the script):&lt;/P&gt;&lt;P&gt;&lt;IMG alt="result.png" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/53962_result.png" style="height: auto;" /&gt;&lt;/P&gt;&lt;P&gt;... using a little of Python code (ugly, I know, but will clean it up and convert it into a toolbox later...)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy
import math

def main():
&amp;nbsp;&amp;nbsp;&amp;nbsp; tbl = r"D:\Xander\GeoNet\MigrationRoutes\gdb\test.gdb\test_tbl"
&amp;nbsp;&amp;nbsp;&amp;nbsp; fc_out = r"D:\Xander\GeoNet\MigrationRoutes\gdb\test.gdb\migration06"
&amp;nbsp;&amp;nbsp;&amp;nbsp; sr = arcpy.SpatialReference(28992)

&amp;nbsp;&amp;nbsp;&amp;nbsp; flds = ("X1", "Y1", "X2", "Y2")
&amp;nbsp;&amp;nbsp;&amp;nbsp; curvature = 0.05 # 5%
&amp;nbsp;&amp;nbsp;&amp;nbsp; pnts_on_curve = 100

&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_lines = []
&amp;nbsp;&amp;nbsp;&amp;nbsp; with arcpy.da.SearchCursor(tbl, flds) as curs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in curs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt1 = arcpy.Point(row[0], row[1])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pnt2 = arcpy.Point(row[2], row[3])
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; line = arcpy.Polyline(arcpy.Array([pnt1, pnt2]), sr)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; length = line.length
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; offset = curvature * length
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delta_x = row[2] - row[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; delta_y = row[3] - row[1]

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # extract points on line
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arr = arcpy.Array()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for i in range(0, pnts_on_curve + 1):
&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; frac = i / float(pnts_on_curve)
&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; pnt = line.positionAlongLine(frac, use_percentage=True)
&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; line_perp = perpendicular_line(line.firstPoint, line.lastPoint, pnt.firstPoint)
&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; asin = math.sin(frac * math.pi)
&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; dist_off = offset * asin
&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; pnt_new = line_perp.positionAlongLine(dist_off, use_percentage=False)
&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; arr.add(pnt_new.firstPoint)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; line_new = arcpy.Polyline(arr, sr)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; lst_lines.append(line_new)

&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CopyFeatures_management(lst_lines, fc_out)


class Coord(object):
&amp;nbsp;&amp;nbsp;&amp;nbsp; def __init__(self,x,y):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.x = x
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; self.y = y

&amp;nbsp;&amp;nbsp;&amp;nbsp; def __sub__(self,other):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # This allows you to substract vectors
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return Coord(self.x-other.x,self.y-other.y)

&amp;nbsp;&amp;nbsp;&amp;nbsp; def __repr__(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Used to get human readable coordinates when printing
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return "Coord(%f,%f)"%(self.x,self.y)

&amp;nbsp;&amp;nbsp;&amp;nbsp; def length(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Returns the length of the vector
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return math.sqrt(self.x**2 + self.y**2)

&amp;nbsp;&amp;nbsp;&amp;nbsp; def angle(self):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; # Returns the vector's angle
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return math.atan2(self.y,self.x)

def normalize(coord):
&amp;nbsp;&amp;nbsp;&amp;nbsp; return Coord(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; coord.x/coord.length(),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; coord.y/coord.length()
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )

def perpendicular(coord):
&amp;nbsp;&amp;nbsp;&amp;nbsp; return Coord(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; coord.length()*math.cos(coord.angle()+math.pi/2),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; coord.length()*math.sin(coord.angle()+math.pi/2)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; )

def perpendicular_line(coord_from, coord_to, coord_at):
&amp;nbsp;&amp;nbsp;&amp;nbsp; length = math.hypot(coord_from.X - coord_to.X, coord_from.Y - coord_to.Y)
&amp;nbsp;&amp;nbsp;&amp;nbsp; a = Coord(coord_from.X, coord_from.Y)
&amp;nbsp;&amp;nbsp;&amp;nbsp; b = Coord(coord_to.X, coord_to.Y)
&amp;nbsp;&amp;nbsp;&amp;nbsp; perp = perpendicular(normalize(a-b))
&amp;nbsp;&amp;nbsp;&amp;nbsp; perp_len = Coord(perp.x*length, perp.y*length)
&amp;nbsp;&amp;nbsp;&amp;nbsp; coord_perp = Coord(perp_len.x+coord_at.X, perp_len.y+coord_at.Y)
&amp;nbsp;&amp;nbsp;&amp;nbsp; return arcpy.Polyline(arcpy.Array([coord_at,
&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;&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Point(coord_perp.x, coord_perp.y)]))


if __name__ == '__main__':
&amp;nbsp;&amp;nbsp;&amp;nbsp; main()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:19:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/creating-polylines-to-track-migration/m-p/760866#M24810</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2021-12-12T08:19:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Polylines to track migration</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/creating-polylines-to-track-migration/m-p/760867#M24811</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Find attached the toolbox. In case of any problems, please post them back. The toolbox was created with ArcGIS 10.3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="tool_dialog.png" class="jive-image image-1" src="https://community.esri.com/legacyfs/online/54065_tool_dialog.png" style="width: 620px; height: 494px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Jan 2015 21:36:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/creating-polylines-to-track-migration/m-p/760867#M24811</guid>
      <dc:creator>XanderBakker</dc:creator>
      <dc:date>2015-01-23T21:36:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Polylines to track migration</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/creating-polylines-to-track-migration/m-p/760868#M24812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for the tool.&amp;nbsp; This looks like what I need.&amp;nbsp; I will give it a try and let you know.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 24 Jan 2015 03:50:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/creating-polylines-to-track-migration/m-p/760868#M24812</guid>
      <dc:creator>SteveCline</dc:creator>
      <dc:date>2015-01-24T03:50:55Z</dc:date>
    </item>
    <item>
      <title>Re: Creating Polylines to track migration</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/creating-polylines-to-track-migration/m-p/760869#M24813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for this information. I will make x,y tables and see if I can get this to work. I am using arcmap 10.1, and I have not used Python yet. Now I will take a class in how to apply it. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rich&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sent from Windows Mail&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 25 Jan 2015 08:09:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/creating-polylines-to-track-migration/m-p/760869#M24813</guid>
      <dc:creator>RichardOwens1</dc:creator>
      <dc:date>2015-01-25T08:09:33Z</dc:date>
    </item>
  </channel>
</rss>

