Wednesday 18 May 2016

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?



Answer



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.



summarize dialog


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.


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...