List of line lengths over areas
I have several areas and 1 line and I'd like to get a list of the partial lengths of the line over each one of the areas. I know that I can split the line in every intersection and I can label each part with its length but I would like to get this information in table format, including an attribute that relates every splitted line with the area over it.
Is it possible to automate?
Thanks in advance.
Best Answers
-
You don't need to manually add it to each segment. Here's an example:
I have a layer of lines in blue and areas in red:
Next I use the crop function to crop the lines to the areas:
Now I right click on the workspace, choose Attribute/Style Functions and then Copy Attributes Between Overlapping/Nearby Features
Now you can copy the feature names from the areas to the lines contained with the areas--just make sure you've checked which attribute you want to be copied in the options box:
In this picture, I've color coded the streams to the area name, so you can see each cropped stream is coded to its enclosing area:
You can now calculate the lengths of the stream segments and export the layer as a csv file.
-
This is a sort of complicated workaround, but it will do the trick.
1) Select your original line, right click on the workspace and choose Advanced Feature Creation Options -> Create New Points from Selected Points and Areas:
In the options window that appears, choose "No - Create Point Features at Every Vertex", then give the layer a name:
2) This will give you a layer of points with the attribute VTX_NUM that gives each point a number starting with 1 at the beginning of the line:
Next, do the crop process I described in my earlier post, so you end up with segments cropped to the basins.
Uncheck every layer except the vertex points and the cropped segments.
The next step is to right click on the workspace, then choose Attribute/Style Functions -> Copy Attributes Between Overlapping/Nearby Features:
In the options window that appears, choose copy attributes from Loaded Points to Loaded Lines, click "Uncheck All" and copy only the VTX_NUM attribute from the points to the line, check "Keep Minimum Attribute Value from Matching "From" Feature" and set the maximum distance from point to line at 1m:
Click on the layer and open the Attribute Editor, click the Show/Hide Attributes and uncheck everything except the VTX-NUM and <Index in Layer> attributes:
Change the sort to Numeric and sort VTX-NUM:
Click on the layer name, choose Options and change the label to <Index in Layer>:
Now the segments will be labeled in order:
Answers
-
It's not quite automation, but you can crop the line to the areas then attribute the name of each area to each line. Then calculate the lengths of each segment, open the Edit Attributes window, select all the segments and export to a csv file. You will end up with a table showing each line segment and the area that it is contained in, if applicable.
-
Thank you JSL. I understand that the part of adding an attribute to each line, as you are suggesting, is totally manual. I wouldn't know how to automate it. If so, this is a huge task.
-
Great @JSL. That is just what I needed. You've saved me a lot of time.
There is something else I'd like to do but don't know how. I would like to order (adding an attribute) the segments from the beginning of the line to the end.
Thanks.
-
Wow @JSL you are a master. I didn't think I could do that with Global Mapper. Thanks a lot. I owe you.
-
I'm having an issue following your instructions. It is not critical but I guess it can be solved. When I order by VFX_NUM I get a list of <index in layer> attributes not following the order so if I add labels they are not following the order. I guess there is a way to renumber <index in layer> in the edit attributes menu but I couldn't find it.
Categories
- 12.8K All Categories
- 5.7K Features Discussion
- 345 Downloading Imagery
- 1.3K Elevation Data
- 385 Georeferencing Imagery Discussion
- 639 GM Script Language
- 54 User Scripts
- 115 GPS Features
- 417 Projection Questions
- 827 Raster Data
- 1.3K Vector Data
- 6.6K Support
- 178 Announcement and News
- 918 Bug Report
- 558 SDK
- 1.2K Suggestion Box
- 3.7K Technical Support
- 570 Other Discussion
- 131 GIS Data Sources
- 27 Global Mapper Showcase
- 239 How I use Global Mapper
- 107 Global Mapper Forum Website