Wednesday, 15 February 2017

Converting Points to Lines in ArcGIS Desktop and retaining attributes of both start and end points?


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?




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...