# Calculate line distances inside of polygons using ArcGIS for Desktop?

I'm working with two data sets:

• NHD polyline stream layer for my entire state
• HUC Watershed boundary Polygons for the entire state

I am looking for a way to calculate the total length of streams within each watershed boundary polygon, and would ideally like to have each polygon then attributed with the sum of stream miles within its boundary.

Can anyone help me?

• What software are you using? May 30, 2014 at 23:10
• I'm using ArcGIS 10.2 May 30, 2014 at 23:28

Assuming your stream polylines do not already have an attribute that states which watershed they belong to, you can run Identity (Advanced license only) or Intersect to get that attribute assigned in a new feature class. This also makes sure your streams actually break at the boundary rather than continuing through multiple areas.

Then you can open the attribute table of the new feature class, right-click the watershed name column, and choose Summarize. Select the name field to summarize on and the length field with sum as the statistic. This will output a table with all the watershed names and the total length of streams contained within each.

Alternatively, as Michael suggests in his comment, you can use the Summary Statistics tool which is more powerful than Summarize. The primary advantage is that it can summarize on multiple (case) fields which Summarize cannot (though you do not need that for this particular problem). With that tool, length would be your Statistic field (type sum) and you would put basin name in as a Case field. Another advantage Michael mentions is that it is a tool that can be called in a Model.

• +1 Spot on @chrisw! The intersect tool has a limit of two feature classes in View and Edit (basic and standard) but that would be adequate for this task. If you are putting this into a model consider summary statistics (Statistics_analysis), it does the same as right click and summarize field. May 31, 2014 at 0:49

I think you are going to have to break (as a node) the road at the polygon edges to do this in vector space.

1. Use Identity Tool in ArcGIS and this should do the trick. Just option that is something like Just ID

Remember to recalculate lengths in the attribute table after the identity (just to be sure)

It will add the polygon details (in this case thee ID) such as name and fid to the roads.

Then Summary Statistics if required to get the sum of lengths using the case field of the Polygon ID

Then just Attribute Join the output summary statistics back to the Polygon IDs to bring the total length into the Polygon attribute table.

1. Actually this seems convoluted now I write it. Maybe just break the roads at the polygon and use a spatial join with the SUM option.
• Dear 'user two seven two three nine', this is very helpful, I am quite an ultimate beginner with arc map, and redoing it, i figured out how you explained in method 1, it does the trick! thank you! Oct 26, 2014 at 7:32