How to create a single line from path region?

Post questions on how to use or achieve an effect in Inkscape.
haris.sarwar
Posts: 5
Joined: Sat Apr 13, 2013 7:16 pm

How to create a single line from path region?

Postby haris.sarwar » Sat Apr 13, 2013 7:32 pm

I am trying to vectorize a map. I have created a sketch from the original image using trace bitmap option.
Output of tracing can be seen in the image below.

SVG Image

Tracing have created outer and inner edge using path and then filled it with black color.
These regions don't have uniform width.

I want to draw a single vectorize line within the black region so that i can have a uniform width less complex output giving a cleaner look.

Can this be done in Inkscape?

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

Re: How to create a single line from path region?

Postby brynn » Sun Apr 14, 2013 2:59 am

Image
Welcome to InkscapeForum!

Trace Bitmap may prove not to be the best approach, if you need precision for this map. If "close enough" will do, and you can start with a very large original map, you can get a better trace. Somehow, and I can't tell you exacly, I think you can use a raster editor to create the large version. But someone else will have to explain that exactly.

Otherwise, if you need a very precise trace, and/or single paths, you'll need to do a manual trace. For the map you've shown us, it shouldn't be very hard. An Inkscape beginner can do it. Although if you need to do multiple different maps, it will be an investment of time.

First import the map. You'll probably get along better with the Pen/Bezier tool, although if you have a very steady mouse hand, the Pencil/Freehand tool might work just as well. You may well figure out those tools on your own, or you can consult the manual and/or the info in my forum signature. And please feel free to ask us questions! It seems that some people can't quite figure it out, so I wrote a detailed tutorial a while ago viewtopic.php?f=6&t=13037

If you'd like to keep the original in the same file with the drawing, you can add a new layer, move the original to it, then hide it :D

haris.sarwar
Posts: 5
Joined: Sat Apr 13, 2013 7:16 pm

Re: How to create a single line from path region?

Postby haris.sarwar » Sun Apr 14, 2013 4:38 am

The image shown earlier is a small part of the following image.

Image

Some parts are not close enough.

I tried to draw manually but it will take a lot of time. I was looking for some automatic process if available in Inkscape.
Using trace bitmap i have come up with this result

Image

I took me about three days to produce the above result but as you can see the lines around the regions are not uniform.
I want to have a uniform look.

User avatar
flamingolady
Posts: 687
Joined: Wed Jun 10, 2009 1:40 pm

Re: How to create a single line from path region?

Postby flamingolady » Sun Apr 14, 2013 4:53 am

Welcome to the forum!
As Brynn said, I'd also do this manually, there are a couple of ways to do it, of course, as with just about everything in Inkscape.
First of all, whatever you do, duplicate the traced item and make a copy of it, on a separate document, so if all else fails, you still have the original (can't stress that enough).
Method to try #1 : Now, highlight all the traced items, then do a Path/Union, that will give you one vector object where you can then manually manipulate the nodes. If you have a lot of nodes, you can start by doing Path/Simplify, or even add in nodes if there aren't enough to move around to keep the shape. You can highlight the entire map and make the stroke a set value now too, so it will look so much better.

Method #2 - Take your original traced map above and lock it (go to Object/ Object Properties/Lock). Now the map can't be moved, can't be worked on, etc. But, it becomes a background where you can now use your pencil or pen tool and manually draw (trace) over it. Once you do that you will have your vector. Even if you have to stop the drawing line, you can later do a Path/Union or Path/Combine to make them one line. However, note that even if you do not make it one path, it's still a vector (vector doesn't mean one path).

Note for both methods: I like the idea of using combine vs union on the cities or whatever they are, because later you may want to make a map of just one city, and that's hard to do if you union everything.
hope this helped, not entirely sure I addressed all of your issues.

rich2005
Posts: 55
Joined: Fri Mar 30, 2012 9:06 pm

Re: How to create a single line from path region?

Postby rich2005 » Sun Apr 14, 2013 5:15 am

I think the problem is due to the Inkscape trace being based (in the past) from potrace which does not have a centerline option.

You can get a centerline using Autotrace.
http://autotrace.sourceforge.net/

but this is old stuff and command line. Works fine in linux and windoze up to WinXP. (broken in Win7 I think)

There is a web front end, does not have all the options of cl but works.

http://www.roitsystems.com/cgi-bin/autotrace/tracer.pl

look for the tick box -> Trace font centerline

This is your svg exported as a png and processed back to a svg
Attachments
mapsketch.svgz
(4.3 KiB) Downloaded 207 times

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

Re: How to create a single line from path region?

Postby brynn » Sun Apr 14, 2013 7:21 am

In my experience, centerline trace is not ideal either. It seems to produce a different kind of anomaly. But it can't hurt to try it. It's hard to explain how it works, but you'll quickly see it after you do a trace. On the plus side, it will give you single paths. They'll just be really funky around intersections.

haris.sarwar
Posts: 5
Joined: Sat Apr 13, 2013 7:16 pm

Re: How to create a single line from path region?

Postby haris.sarwar » Sun Apr 14, 2013 7:49 am

I have looked the output of auto trace you have generated. I want to have this type of output but lot of edge details are lost in it.
I will try to play with different options of auto trace so that edge detail loss is minimum.

Apart from that i came up with another idea of using bucket to fill the inside region and then using fixed stroke to get a cleaner look.
As i have done in the following image.

SVG Image

But the problem with this option is that there is gap between the objects.
Is there any way to remove this gap?

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: How to create a single line from path region?

Postby ragstian » Sun Apr 14, 2013 7:54 am

Hi.

What part of the world is the map from.
Might be better to make it from scratch using a small script.
Can give you an example.

RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

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

Re: How to create a single line from path region?

Postby brynn » Sun Apr 14, 2013 8:42 am

On the Paint Bucket control bar is a Grow/Shrink option. I've found a value of 0.5 is ideal if you use a 1 px wide stroke (to fill the gaps but not extend outside the border.. But there are a few situations where that won't work either. For example, tight corners or curves still may not be filled. If the map you're using has any text on it, the Bucket tool won't fill that area. You can probably adjust the Threshold, to help some with that part.

In general, I'd say you may get a better result using the Bucket tool. But it will still be tedious. If it were me, I'd bite the bullet and hand trace it.

(Ragnar, Gilgit or Kashmir give you any clues? The forum cuts that off. Love to see how a script can draw a map!)

haris.sarwar
Posts: 5
Joined: Sat Apr 13, 2013 7:16 pm

Re: How to create a single line from path region?

Postby haris.sarwar » Sun Apr 14, 2013 9:10 am

Map is of pakistan but the division is not based on cities instead is based on constituencies.
How can we draw map using a script?

Yes i could try to minimize the gap by growing the pixel by half but still there will be gaps.

Won't hand tracing be difficult for whole map?

User avatar
ragstian
Posts: 1181
Joined: Thu Oct 11, 2012 2:44 am
Location: Stavanger-Norway

Re: How to create a single line from path region?

Postby ragstian » Sun Apr 14, 2013 1:04 pm

Hi

brynn;
Love to see how a script can draw a map!

Drawing a map using a script is relatively easy.
There are a lot of good sites on the net which will tell you how.
The image below was made by using code from this page;
http://www.geophysique.be/2013/02/12/matplotlib-basemap-tutorial-10-shapefiles-unleached-continued/

Image
As the data for the borders and the counties (Administrative areas?) were from different sources they don't match perfectly.
(Click image for larger version.)

My only contribution to get it to work was to input the right coordinates for
Pakistan and finding the data for the Pakistani counties (or whatever they are? Administrative areas?
For Asian countries it's hard to find "free" data).

haris.sarwar;
The SVG file is too big to attach here. However you can get it from my dropbox here; http://goo.gl/R2pwJ
As the data for the borders and the counties (Administrative areas?) were from different sources they don't match perfectly.
Data lifted from this site http://www.diva-gis.org/gdata

Another page worth looking at if you want to pursue the "Python Map Route"; http://vis4.net/blog/posts/rendering_country_maps/
If you go that route I can recommend downloading and installing the pythonxy distribution - made for the "techie" types! http://code.google.com/p/pythonxy/
It will have all the tools necessary for making the maps.

Good Luck
RGDS
Ragnar
Last edited by ragstian on Tue Apr 16, 2013 5:04 am, edited 2 times in total.
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar

haris.sarwar
Posts: 5
Joined: Sat Apr 13, 2013 7:16 pm

Re: How to create a single line from path region?

Postby haris.sarwar » Sun Apr 14, 2013 5:46 pm

Thanks
Ragnar
I didn't knew about this way of crating a map. I could not find any svg map so i decided to create it using tracing.
I will try to follow your direction.

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

Re: How to create a single line from path region?

Postby brynn » Tue Apr 16, 2013 3:16 am

Wow! That's amazing Ragnar. Why are all the individual objects "Clones"? The scripting is over my head, but it's amazing :D

haris.sarwar, hand tracing is not difficult. But on a map with so much detail, it will be time consuming.
I've seen some awesome maps at WikiMedia / Wiki Commons, and often SVG files are available for download. Maybe you could search there?


Return to “Help with using Inkscape”