I have a table with animal location points. I need to calculate movement distances between points from the same animal. So I thought I would create lines from the points, which are linked by an animal ID code, then calculate the line distance of each movement.

I have a table structure similar to this:

FID; AnimalID; Date; UID; Weight

The AnimalID field links observations from the same animal, the date is the sequential ordering field, UID is a copy of the FID so that each record has a unique ID code and Weight is a measurement of the animal at the time.

Some animals were only located once (these get excluded by the creation of lines so is usually not an issue and I don't want to delete all of the single observations from the dataset every time I run this). The remaining animals are located multiple times.Of note is that some location points are identical for different individuals.

I am using ArcGIS Desktop 10.0 with spatial analyst extension.

At the end I need to have the following fields in the attribute table (or something like it): AnimalID; Date 1; Date2; Weight1; Weight2; Distance

So I have looked at ETGeowizards Points to Line tool and this is a really good toolset. I specify the ID field as the AnimalID, the order field as Date and it allows me to attach the attributes of the UID field of the start and end point. It is almost what I need. HOWEVER, it creates a single polyline for each animal and I need to have different segments. While I can convert it to multipart, I lose the important attribute information (date, weight) that I can't link back to the original data.

I also tried the point to line tool in Geospatial Modelling Environment (GME) which is also almost suitable. This allows me to create multipart lines with the AnimalID transferred over. However, I can't include a UID field from each point, so I can't join the specific attributes of both points over. I tried to do a spatial join (one to one). However, as I have more than 2 points that overlap with some lines, this causes incorrect attributes to be transferred. A one-to-many spatial join causes replicates of the line (as there are two points to each line), plus the erroneous ones from overlapping points from other animals. It seems a nightmare to try and extract the correct ones from this.

As far as I can see, the Point to Line tool in GME is most appropriate if I could get it to copy a From_UID and a TO_UID fields over. Then I could do a join of the line layer to the original point layer -> export to shapefile -> do another join of the exported line layer with the original point layer (to get the attributes for the second point) -> export shapefile. Then I add a field -> calculate geometry for the distance calculation.

FYI this is what the GME Point to Line tool does:

The tool allows a user to select a field name from the points layer to group the line segments, a field name to sort the groups (optional), and the point layer fields to be copied to the line layer. Line segments are created from two points with the same attribute in the group field. The attributes for the line segment are taken from the first point. The points DO NOT have to be sorted by group attribute and order.

I have no experience writing scripts but hopefully someone can think of a workaround.

I am used to an older version of ArcGIS, so I used ET Geowizard tools first. But yes, you can do this with the ArcGIS toolset Point to Lines tool. But still can't retain attributes or a to_ and from_ field.

Any more suggestions?

  • With Points To Line and ArcPy cursors this looks relatively straightforward but without Python I would not like to tackle it. I don't see any need for ET GeoWizards, GME or Spatial Analyst and it should all be doable with a Basic/ArcView license.
    – PolyGeo
    Commented May 17, 2013 at 8:11
  • can you post a small sample file for those interested in testing out ideas for solutions so we don't have to make up a test dataset as a first step?
    – Llaves
    Commented May 27, 2013 at 4:05

2 Answers 2


Well I couldn't work out how to tie the original attributes back to the lines in ArcGIS. But I ended up getting the job done in R using the AdehabitatLT package. The instruction manual can be found here: http://cran.r-project.org/web/packages/adehabitatLT/vignettes/adehabitatLT.pdf

Here are the steps:

  • import in data table with animalID; Date; Easting; Northing; variable1; variable2 fields
  • convert date field to a format suitable for AdehabitatLT
  • Create trajectories (movement lines)
  • Convert trajectories to a dataframe
  • Delete out the animals that only had one location points (using subset)
  • Export the dataframe to a .csv for use in a stats package (this has distance and time between relocations in the fields plus the original data)
  • Convert the dataframe back to a trajectory type
  • Export as shapefile of movement lines using the maptools package to view in ArcGIS.

The trajectory lines created using this method for viewing in ArcGIS still don't have the original fields in the attribute table and are just one line per animal. However, the dataframe export into excel gives me the information I need to do the analyses, so it works well enough.

It would be neater if we had this info in the attribute table for each line. But it gets the job done.

I can post the script if anyone is interested.

I'm still interested to hear if I can do this in ArcGIS.



I found myself just asking this same question. I went the dictionary route in Python (using some ArcPy of course) because ArcGIS Table Join is slow. Here's my code:

# these are the fields I want in my final polyline.shp, in dictionary format
finalfields = \
    'my_ID': 'SHORT',
    'my_name': 'TEXT',
    'my_date': 'TEXT',
    'my_fieldA': 'DOUBLE',
    'my_fieldB': 'TEXT'

# create my final polyline.shp
arcpy.PointsToLine_management(shp_nodes, shp_polyline, Line_Field='my_ID', Sort_Field='node_id')

# now do dictionary mapping; note that 'my_ID' field is unique; it's basically the primary key
existing_fields = [field.name for field in arcpy.ListFields(shp_nodes)]
    for field in finalfields:
        ftype = finalfields.get(field)

        if field in existing_fields:
            with arcpy.da.SearchCursor(shp_nodes, ['my_ID', field]) as cursor:
                this_dict = dict(r for r in cursor)

            arcpy.AddField_management(shp_polyline, field, ftype, field_is_nullable="NULLABLE")
            with arcpy.da.UpdateCursor(shp_polyline, ['my_ID', field]) as cursor:
                for row in cursor:
                    idCheck = row[0]
                    if idCheck in this_dict:
                        row[1] = this_dict[idCheck]
        del this_dict, ftype

# now my final polyline.shp has the fields I wanted with the values 'mapped' or 'joined' from the shp_nodes (aka point shp)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.