Measure and tabulate sum of lengths for selected paths?

Post questions on how to use or achieve an effect in Inkscape.
avamk
Posts: 12
Joined: Fri Jul 27, 2012 12:42 am

Measure and tabulate sum of lengths for selected paths?

Postby avamk » Fri Jul 27, 2012 12:58 am

Hello,

I am trying to digitise raster images by tracing over its features - think plant roots or branches - with lines (and I am willing to use all freehand curves or segmented lines). I am planning to group the lines into different categories by using layers in the Inkscape document.

Next, I would like to measure the total length of the lines in each group. Having a scale to convert from pixels to, say, centimetres is nice but not necessary.

I found this forum post which suggested using the Extensions -> Visualise Path -> Measure tool. However:

(1) It didn't work for me running Inkscape 0.48.2 r9819 installed via .dmg download from the Inkscape website on Mac OS X 10.6.8 with XQuartz 2.7.2 (xorg-server 1.12.2). When I select a curve and run the tool, this error pops up:

Traceback (most recent call last):
File "measure.py", line 35, in <module>
locale.setlocale(locale.LC_ALL, '')
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/locale.py", line 494, in setlocale
return _setlocale(category, locale)
locale.Error: unsupported locale setting


It looks like some sort of locale setting issue, but I have no idea how to fix it.

(2) The tool says it will measure the length of a path and add a text-on-path object with the length. However, my goal is to measure the *sum* of all lines in a layer, and be able to easily tabulate that into a spreadsheet. Would this tool work for that purpose, assuming I get it to work?

The forum post I referenced also suggested using the ImageJ tool for this kind of measurements. I tried it, including an enhanced version called Fiji, but the problem is that it is difficult to manipulate the paths once you make them. For example, the UI makes it difficult to move the paths on the canvas, and impossible to slice paths unless you do some fancy scripting, among other issues.

I hope this describes my issue. Any suggestions on how I can measure the sum of lengths for a select group of paths in Inkscape would be appreciated. Thank you in advance for your replies.

User avatar
brynn
Posts: 10309
Joined: Wed Sep 26, 2007 4:34 pm
Location: western USA
Contact:

Re: Measure and tabulate sum of lengths for selected paths?

Postby brynn » Fri Jul 27, 2012 8:26 am

Image
Welcome to InkscapeForum!

There are some issues specific to Macs with Inkscape. I don't know if this extension is part of that. Here's all the info I know about Mac issues with Inkscape: http://wiki.inkscape.org/wiki/index.php ... fic_issues. There are a bunch of extensions that aren't packed with Inkscape, so just in case there might be one that would work for you, here's that list: http://wiki.inkscape.org/wiki/index.php ... Repository.

I'm not very familiar with Macs, but other members are, and I'm sure someone will be along soon, who can answer more specifically :D

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Measure and tabulate sum of lengths for selected paths?

Postby ~suv » Fri Jul 27, 2012 4:53 pm

avamk wrote:(1) It didn't work for me running Inkscape 0.48.2 r9819 installed via .dmg download from the Inkscape website on Mac OS X 10.6.8 with XQuartz 2.7.2 (xorg-server 1.12.2). When I select a curve and run the tool, this error pops up:
(…)
It looks like some sort of locale setting issue, but I have no idea how to fix it.

IIRC this locale issue may occur if Inkscape's launcher script inside the Mac OS X application bundle fails to properly detect the language settings from the system (check the console log for messages from Inkscape for "Setting language: " and "Using the fallback 'C' locale").

A known workaround is to explicitly set $LANG in Inkscape's launcher script, overriding any settings extracted with the 'defaults' command:

Steps:
  1. install a copy of Inkscape.app into your user account
  2. select the copy of Inkscape.app in the Finder, choose 'Show package contents…' from the context menu
  3. browse to 'Contents/Resources/bin'
  4. open the file 'inkscape' in a plain-text editor
    (TextEdit might work on Snow Leopard (it doesn't on Lion), but I would recommend to use a real text editor, e.g. TextWrangler, Sublime 2, or MacVim)
  5. before line 127, insert a new line with this code:

    Code: Select all

    export LANG="en_US.UTF-8"
  6. save your edits (IMPORTANT: make sure that no hidden suffix is added to the file)
  7. launch the modified Inkscape.app and try again to use 'Extensions > Visualize Path > Measure Path…'
See also: Comments 3-11 in #406662 (Note: please don't download patches or files from those comments, since they might be based on older versions of 'Inkscape.app')

avamk wrote:The tool says it will measure the length of a path and add a text-on-path object with the length. However, my goal is to measure the *sum* of all lines in a layer, and be able to easily tabulate that into a spreadsheet. Would this tool work for that purpose, assuming I get it to work?

Not really - the extension has no option to sum up the lengths of several individual paths into a single overall length, nor can you easily automate exporting the text containing the measured lengths from Inkscape into a spread sheet.

Existing workaround with 'Measure Path…':
To measure the overall length of multiple paths on the same layer, you need to combine the paths into a single path first (each individual path will be converted into a sub-path): 'Ctrl+A', 'Ctrl+K' (or menu 'Path > Combine').

avamk
Posts: 12
Joined: Fri Jul 27, 2012 12:42 am

Re: Measure and tabulate sum of lengths for selected paths?

Postby avamk » Sat Jul 28, 2012 4:31 am

I followed your steps to edit the "inkscape" file in jEdit, tried the Visualize Path tool again and it worked!

Combining paths then using the tool also worked. This might be viable, because I only have three to four layers - each with a bunch of paths - that I need to combine. So I could end up with four numbers to manually copy and paste into my spreadsheet, which is not too bad.

Thank you so much for your detailed answer! Inkscape now looks like a very promising tool for what I would like to do.

In case someone else has a better solution, please let me know, too!

aiden carter
Posts: 1
Joined: Sun Nov 13, 2016 3:55 am

Long Path Tool

Postby aiden carter » Sun Nov 13, 2016 3:58 am

The Long path tool is the very best program for error, unlock solution.
Try it and solved your problem.
I used the long path tool and I solved my error, unlocks problem solution.


Return to “Help with using Inkscape”