<?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: Sequencing and indexing bus stops based on network spatial weights in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722628#M23937</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Not a stupid question at all!&amp;nbsp; You need to read in your shapefile or feature class using a search cursor (arcpy.da.SearchCursor).&amp;nbsp; You can read in the shape geometry using the SHAPE@ keyword, and that should give you a point or a line geometry object.&amp;nbsp; You then feed the point and line geometry objects to the measureOnLine method.&amp;nbsp; There are some SearchCursor examples here: &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000011000000"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000011000000&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks! Trying that now.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Mar 2014 22:19:52 GMT</pubDate>
    <dc:creator>SuiTao</dc:creator>
    <dc:date>2014-03-10T22:19:52Z</dc:date>
    <item>
      <title>Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722621#M23930</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello guys, &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a problem that might be less straightforward, but please bear with me.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a polyline shapefile that contains all the bus routes (each bus route has an id, like 111, 120), and a point shape file that contains all the bus stops (each stop has an id, like 30102, 5061, and lat and long for each point). &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Based on these two files, my goal is to generate a table that sequence stops (marked as 1, 2, 3...) for all the bus routes based on the sequence the stops are passed through. The attached file gives an example of such a table.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have a logic to do this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(1) Find the stops for all the bus routes based on spatial relationship (for example, intersecting);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(2) Calculate the network spatial weights for the stops on each route (it is a gis tool called 'generate spatial network weights', the resulting spatial weights are between 0-1, the larger the value the closer the two points are and vice versa);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(3) Identify the first stop (origin) for each route and mark them as 1st stop;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;(4) Re-sequence the stops based on the spatial weight (for example, find the next stop closest to the first stop and mark it 2nd stop, and continue this process till there's no more stops left).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I can do the first three steps using the tools of gis. The problem is the final step: I cannot do it manually since there are over 10,000 bus stops and over 900 bus routes. So my question is that is there any scripts or any other tools to automate this process to generate the table I want? Of course you don't have to follow my logic. The sole direction is to generate the attached table for all the routes.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm very desparate to find a solution so please don't hesitate with any suggestions. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sui Tao&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Mar 2014 00:25:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722621#M23930</guid>
      <dc:creator>SuiTao</dc:creator>
      <dc:date>2014-03-04T00:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722622#M23931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, Sui Tao.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I will try to help you out with this.&amp;nbsp; What version of ArcGIS are you running?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There's a new python method in ArcGIS 10.2.1 that would be perfect for what you're trying to do.&amp;nbsp; It allows you to quickly find the distance along a line that a point falls.&amp;nbsp; You could find the distance that each stop falls along the route they're assigned to and sort by that distance to determine the order.&amp;nbsp; You have to create a Polyline geometry object for your route line and a Point geometry object for each stop.&amp;nbsp; Then use the measureOnLine() method.&amp;nbsp; You would end up with something like:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;dist_along_route = lineGeom.measureOnLine(ptGeom)&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;SPAN&gt;See &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.2/index.html#//018z00000070000000" rel="nofollow" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//018z00000070000000&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Unfortunately, this simple method isn't available in ArcGIS versions prior to 10.2.1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you don't have 10.2.1 yet, you could accomplish the same thing using the linear referencing tools.&amp;nbsp; See &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://resources.arcgis.com/en/help/main/10.2/index.html#//003m00000002000000" rel="nofollow" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//003m00000002000000&lt;/A&gt;&lt;SPAN&gt;.&amp;nbsp; You would first use the Create Routes tool on your polyline routes.&amp;nbsp; This just generates measures along those route lines so you can return the distance along the lines later.&amp;nbsp; Then, you would use Locate Features Along Routes to determine the distance along each route that each stop falls.&amp;nbsp; You could then extract the distance from the resulting table and sort it to determine your stop sequence.&amp;nbsp; You would want to run the tool separately for each route in your system.&amp;nbsp; If you have a lot of routes, this will likely be time consuming, as the linear referencing tools tend to run a bit slowly.&amp;nbsp; The 10.2.1 Geometry method I mentioned above is much faster.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know if this doesn't answer your question or if I can provide any further assistance.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Mar 2014 14:44:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722622#M23931</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2014-03-04T14:44:32Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722623#M23932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hello, Sui Tao.&lt;BR /&gt;&lt;BR /&gt;I will try to help you out with this.&amp;nbsp; What version of ArcGIS are you running?&lt;BR /&gt;&lt;BR /&gt;There's a new python method in ArcGIS 10.2.1 that would be perfect for what you're trying to do.&amp;nbsp; It allows you to quickly find the distance along a line that a point falls.&amp;nbsp; You could find the distance that each stop falls along the route they're assigned to and sort by that distance to determine the order.&amp;nbsp; You have to create a Polyline geometry object for your route line and a Point geometry object for each stop.&amp;nbsp; Then use the measureOnLine() method.&amp;nbsp; You would end up with something like:&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;dist_along_route = lineGeom.measureOnLine(ptGeom)&lt;/PRE&gt;&lt;BR /&gt;See &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//018z00000070000000"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//018z00000070000000&lt;/A&gt;.&lt;BR /&gt;Unfortunately, this simple method isn't available in ArcGIS versions prior to 10.2.1.&lt;BR /&gt;&lt;BR /&gt;If you don't have 10.2.1 yet, you could accomplish the same thing using the linear referencing tools.&amp;nbsp; See &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//003m00000002000000"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//003m00000002000000&lt;/A&gt;.&amp;nbsp; You would first use the Create Routes tool on your polyline routes.&amp;nbsp; This just generates measures along those route lines so you can return the distance along the lines later.&amp;nbsp; Then, you would use Locate Features Along Routes to determine the distance along each route that each stop falls.&amp;nbsp; You could then extract the distance from the resulting table and sort it to determine your stop sequence.&amp;nbsp; You would want to run the tool separately for each route in your system.&amp;nbsp; If you have a lot of routes, this will likely be time consuming, as the linear referencing tools tend to run a bit slowly.&amp;nbsp; The 10.2.1 Geometry method I mentioned above is much faster.&lt;BR /&gt;&lt;BR /&gt;Let me know if this doesn't answer your question or if I can provide any further assistance.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi Melinda,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for the quick reply. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm using arcGIS 10.1, but I can update to 10.2. If not, I will try to use the second method of linear referencing tools.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The measureOnLine code you provided seems pretty tempting. I will try that first and let you know the results asap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sui&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Mar 2014 22:41:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722623#M23932</guid>
      <dc:creator>SuiTao</dc:creator>
      <dc:date>2014-03-04T22:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722624#M23933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Great.&amp;nbsp; Just to clarify, the measureOnLine() function isn't available in 10.2, only in 10.2.1, which is a separate product.&amp;nbsp; If you're going to upgrade, make sure you can upgrade all the way to 10.2.1 and not just 10.2.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Mar 2014 22:43:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722624#M23933</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2014-03-04T22:43:07Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722625#M23934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Alright. Will keep that in mind. Many thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 04 Mar 2014 23:39:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722625#M23934</guid>
      <dc:creator>SuiTao</dc:creator>
      <dc:date>2014-03-04T23:39:31Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722626#M23935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Melinda, &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Just got GIS 10.2.1. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry, but I have another possibly stupid question (I'm a newbie to arcpy...). So I alreay have the shapefile feature classes of the bus routes and points, how do I convert them into geometry objects? Or do I just run the measureOnLine script using these feature classes? &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sui&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Mar 2014 01:56:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722626#M23935</guid>
      <dc:creator>SuiTao</dc:creator>
      <dc:date>2014-03-10T01:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722627#M23936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not a stupid question at all!&amp;nbsp; You need to read in your shapefile or feature class using a search cursor (arcpy.da.SearchCursor).&amp;nbsp; You can read in the shape geometry using the SHAPE@ keyword, and that should give you a point or a line geometry object.&amp;nbsp; You then feed the point and line geometry objects to the measureOnLine method.&amp;nbsp; There are some SearchCursor examples here: &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000011000000"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000011000000&lt;/A&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Mar 2014 20:21:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722627#M23936</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2014-03-10T20:21:38Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722628#M23937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Not a stupid question at all!&amp;nbsp; You need to read in your shapefile or feature class using a search cursor (arcpy.da.SearchCursor).&amp;nbsp; You can read in the shape geometry using the SHAPE@ keyword, and that should give you a point or a line geometry object.&amp;nbsp; You then feed the point and line geometry objects to the measureOnLine method.&amp;nbsp; There are some SearchCursor examples here: &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000011000000"&gt;http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000011000000&lt;/A&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks! Trying that now.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Mar 2014 22:19:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722628#M23937</guid>
      <dc:creator>SuiTao</dc:creator>
      <dc:date>2014-03-10T22:19:52Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722629#M23938</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Melinda,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Just tried the acrpy.da.SearchCursor coupled with measureOnLine. Not surprisingly it did not work since I probably coded in a wrong way (but logicall in the right direction I hope). So could you please have a look at the codes and comment on them?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# import stop feature class and create geometry objects&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; fcStop = 'C:/shapefile/bus_stops.shp'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; stopGeom = arcpy.da.SearchCursor(fcStop,['SHAPE@'])&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# import route feature class and create geometry objects&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; fcRoute = 'C:/shapefile/routes.shp'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; routeGeom = arcpy.da.SearchCursor(fcRoute,['SHAPE@'])&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#measure distance on route&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; dist_along_route = routeGeom.measureOnLine(stopGeom)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#the results were&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "&amp;lt;interactive input&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'da.SearchCursor' object has no attribute 'measureOnLine'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also tried another code 'arcpy.CopyFeatures_management' to create geometry objects, the results were the same.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sui&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2014 04:33:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722629#M23938</guid>
      <dc:creator>SuiTao</dc:creator>
      <dc:date>2014-03-11T04:33:45Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722630#M23939</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Melinda,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I did a bit more searching and changed the script as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# import stop feature class and create geometry objects&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; fcStop = 'C:/shapefile/bus_stops.shp'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; cursorStop = arcpy.da.SearchCursor(fcStop,['SHAPE@'])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; stopGeom = cursorStop.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# import route feature class and create geometry objects&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; fcRoute = 'C:/shapefile/routes.shp'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; cursorRoute = arcpy.da.SearchCursor(fcRoute,['SHAPE@'])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; routeGeom = cursorRoute.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#measure distance on route&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; dist_along_route = routeGeom.measureOnLine(stopGeom,FALSE)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;This returned the result:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Traceback (most recent call last):&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; File "&amp;lt;interactive input&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;AttributeError: 'tuple' object has no attribute 'measureOnLine'&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does that mean the script measureOnLine not exist? BTW, I use gis 10.2.1 and pythonwin 2.7.5&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sui&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Mar 2014 02:02:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722630#M23939</guid>
      <dc:creator>SuiTao</dc:creator>
      <dc:date>2014-03-12T02:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722631#M23940</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Melinda,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry for this heavy replying. I did more change to the script and the measureOnLine finally works. Here's the script:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# import stop feature class and create geometry objects&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; fcStop = 'C:/shapefile/bus_stops.shp'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; cursorStop = arcpy.da.SearchCursor(fcStop,['STOP_ID','SHAPE@'])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; stopGeom = cursorStop.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; stopGeom = stopGeom[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;# import route feature class and create geometry objects&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; fcRoute = 'C:/shapefile/routes.shp'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; cursorRoute = arcpy.da.SearchCursor(fcRoute,['SHAPE@'])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; routeGeom = cursorRoute.next()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; routeGeom = routeGeom[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#measure distance on route&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; dist_along_route = routeGeom.measureOnLine(stopGeom,FALSE)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;#print results&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;gt;&amp;gt;&amp;gt; print dist_along_route&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The above script generates a value of 26983.41708113748. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think it calculates the distance of the first stop to the first route. I checked the stop and the route, turned out the stop is not on the route. So two more questions:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1) How to interpret the meaning of this 'distance'? Is it euclidean distance?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2) For each route, how to calculate the distances of stops that only falls on this route? Should I generate separate point shpfiles for each route?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Again, sorry for all the troubles, and many thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sui&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Mar 2014 06:33:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722631#M23940</guid>
      <dc:creator>SuiTao</dc:creator>
      <dc:date>2014-03-12T06:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722632#M23941</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Glad you figured it out.&amp;nbsp; Yes, the SearchCursor returns items in a tuple.&amp;nbsp; You could have chosen to return more than one field (in addition to SHAPE@), and it would have returned something like (SHAPE@, Field, Field), so it makes sense that you have to use a [0] to get the first item in the tuple (even if there is only one item in it).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The distance is, I believe, the distance along the route in the units of the coordinate system used by the route.&amp;nbsp; If it's in a geographic coordinate system, you should probably project it into something appropriate for the area you're studying.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Do your stops have a route ID associated with them?&amp;nbsp; If so, you can use a loop to loop through the routes. For each route, you can use MakeFeatureLayer on the stops to select only the stops associated with the route ID, and then do the SearchCursor on the feature layer and loop through those stops to calculate the distance along the line.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Something like this (which I didn't test, so it might not be perfect):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;cursorRoute = arcpy.da.SearchCursor(fcRoute,['SHAPE@', 'RouteID'])
for route in cursorRoute:
&amp;nbsp;&amp;nbsp;&amp;nbsp; RouteID = route[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; routeGeom = route[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; where = '"RouteID" = %s' % str(RouteID)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.management.MakeFeatureLayer(fcStop, "Stops", where)
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursorStop = arcpy.da.SearchCursor(fcStop,['STOP_ID','SHAPE@'])
&amp;nbsp;&amp;nbsp;&amp;nbsp; for stop in cursorStop:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stopGeom = stopGeom[1] # Looks like the geometry is the second item in your tuple here
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dist_along_route = routeGeom.measureOnLine(stopGeom,FALSE)&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:54:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722632#M23941</guid>
      <dc:creator>MelindaMorang</dc:creator>
      <dc:date>2021-12-12T06:54:37Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722633#M23942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Glad you figured it out.&amp;nbsp; Yes, the SearchCursor returns items in a tuple.&amp;nbsp; You could have chosen to return more than one field (in addition to SHAPE@), and it would have returned something like (SHAPE@, Field, Field), so it makes sense that you have to use a [0] to get the first item in the tuple (even if there is only one item in it).&lt;BR /&gt;&lt;BR /&gt;The distance is, I believe, the distance along the route in the units of the coordinate system used by the route.&amp;nbsp; If it's in a geographic coordinate system, you should probably project it into something appropriate for the area you're studying.&lt;BR /&gt;&lt;BR /&gt;Do your stops have a route ID associated with them?&amp;nbsp; If so, you can use a loop to loop through the routes. For each route, you can use MakeFeatureLayer on the stops to select only the stops associated with the route ID, and then do the SearchCursor on the feature layer and loop through those stops to calculate the distance along the line.&lt;BR /&gt;&lt;BR /&gt;Something like this (which I didn't test, so it might not be perfect):&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;cursorRoute = arcpy.da.SearchCursor(fcRoute,['SHAPE@', 'RouteID'])
for route in cursorRoute:
&amp;nbsp;&amp;nbsp;&amp;nbsp; RouteID = route[1]
&amp;nbsp;&amp;nbsp;&amp;nbsp; routeGeom = route[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; where = '"RouteID" = %s' % str(RouteID)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.management.MakeFeatureLayer(fcStop, "Stops", where)
&amp;nbsp;&amp;nbsp;&amp;nbsp; cursorStop = arcpy.da.SearchCursor(fcStop,['STOP_ID','SHAPE@'])
&amp;nbsp;&amp;nbsp;&amp;nbsp; for stop in cursorStop:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; stopGeom = stopGeom[1] # Looks like the geometry is the second item in your tuple here
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dist_along_route = routeGeom.measureOnLine(stopGeom,FALSE)&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks Melinda. Looks much closer to what I want. Trying this right away.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 06:54:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722633#M23942</guid>
      <dc:creator>SuiTao</dc:creator>
      <dc:date>2021-12-12T06:54:40Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722634#M23943</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Another issue: for one certain route, if the stops (points) are not actually on this route (polyline). Is it still OK to use measureOnLine to calculate distance?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 02:08:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722634#M23943</guid>
      <dc:creator>SuiTao</dc:creator>
      <dc:date>2014-03-13T02:08:31Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722635#M23944</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Sorry, a second issue: I'm still confused about how the calculation is defined of measureOnLine. In arcGIS resource it says 'A point (PointGeometry or Point) that is used to measure from the start point of the polyline.' So how does it identify start point? Does it automatically find the first point when the polyline is created?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 04:55:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722635#M23944</guid>
      <dc:creator>SuiTao</dc:creator>
      <dc:date>2014-03-13T04:55:39Z</dc:date>
    </item>
    <item>
      <title>Re: Sequencing and indexing bus stops based on network spatial weights</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722636#M23945</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Melinda,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tested the method on one route, and the resulting sequence of stops (they are not even on the route/polyline but only within a certain distance to the route) based on the calculated online distance is correct, which is amazing! I did not define the start nor end point of the route, but it seems this method automatically found the start point. I'm still curious about the calculation method. But it seems working out. Will test them on all the routes and stops to reassure.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Many thanks!&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Sui&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Mar 2014 07:15:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/sequencing-and-indexing-bus-stops-based-on-network/m-p/722636#M23945</guid>
      <dc:creator>SuiTao</dc:creator>
      <dc:date>2014-03-13T07:15:49Z</dc:date>
    </item>
  </channel>
</rss>

