Extracting a rectangle area as SVG

Post questions on how to use or achieve an effect in Inkscape.
SwineDK
Posts: 10
Joined: Thu Jan 16, 2014 12:56 am

Extracting a rectangle area as SVG

Postby SwineDK » Thu Jan 16, 2014 1:34 am

Hi y'all,

I am trying to cut out a part of an existing SVG, because I don't need the full SVG.
I am new to Inkscape, but have spent the whole day looking at tutorials and videos to get this done, but I can't see how it is possible without doing a large amount of work - work I don't mind doing, but would rather NOT do :-)

The original image is a europe-map from Wikimedia, see the bottom for links. I want to cut out a rectangle of the map, that cuts through Turkey, Russia, Norway and Africa.

I have found out that I can use the :tool_eraser: to delete paths from certain objects, but when it is controlled by my unsteady hand, it will not be a pretty straight line, which I want :)
I Also found a tutorial, specifying that it is possible to use Object > Clip > Set. Unfortunately the actual data will remain and the image would therefore not be optimal for the web in this form.

Are there any way to define a path or maybe some guidelines, on which all should be cropped to, where the excess data is removed?

I am using Inkscape version 0.48.4 r9939 on Windows 7.


Related links:
image: http://commons.wikimedia.org/wiki/File: ... daries.svg
The tutorial, that I found: http://inkscapetutorials.wordpress.com/ ... -inkscape/
Related Forum thread: viewtopic.php?f=5&t=6813


Yours sincerely
Steen Nielsen

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Extracting a rectangle area as SVG

Postby Lazur » Sun Jan 19, 2014 9:41 pm

Welcome aboard!

It's more of manual workig, node editing.
If you place a rectangle on the right area, you can use the snapping feature too for making straight edges.
http://www.inkscapeforum.com/viewtopic.php?f=5&t=15626

Good luck!

SwineDK
Posts: 10
Joined: Thu Jan 16, 2014 12:56 am

Re: Extracting a rectangle area as SVG

Postby SwineDK » Mon Jan 20, 2014 9:14 pm

Thank you for the reply.

Hmm, dammit.. Manuel labour ;-)

Maybe it is worth as a feature-request, if it isn't already on the list.
it shouldn't be a big thing, for the right people, to make it possible in Inkscape.

It should just be an option called "Crop", which does a few things, such as:

* Find intersections on paths and set new nodes on this intersection (should be possible to do fairly easy mathematically).
* Remove all nodes/paths outside selection.

There might be more to do, but these things would be a good start.

Lazur
Posts: 4717
Joined: Tue Jun 14, 2016 10:38 am

Re: Extracting a rectangle area as SVG

Postby Lazur » Mon Jan 20, 2014 10:01 pm

The intersect option (Ctrl+*) should do that.
Only drawback is that the path will get recalculated, adding a small error to each coordinates of the nodes.

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

Re: Extracting a rectangle area as SVG

Postby ragstian » Tue Jan 21, 2014 7:35 am

Hi.

There are always more than one way to "skin a cat' - even in Inkscape.
The image you are starting with is literally a "patchwork" with objects on top of each other - in places several layers deep - making it difficult to do the extraction easily in Inkscape.
One method to get what you want is to use the python programming language. Python has a lot of available libraries to do "anything".
For your map you would want the matplotlib and basemap libraries.
One way to get most of the needed libraries for "scientific" computing is to install pythonxy from here; http://code.google.com/p/pythonxy/
Python is free of charge - opensource.

With just a few lines of code:

Code: Select all

from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
 
map = Basemap(projection='merc', lat_0=31.6, lon_0=1,
    resolution = 'i', area_thresh = 0.1,
    llcrnrlon=1.0, llcrnrlat=30.0,
    urcrnrlon=40.0, urcrnrlat=72.0)
 
map.drawcoastlines(linewidth=0.5)
map.drawcountries(linewidth=0.5)
map.fillcontinents(color='#FFFFD0',lake_color='#9FC7F4')
map.drawmapboundary(fill_color=('#9FC7F4'))
plt.savefig('SwineDK_Map1.svg')
plt.show()

You can get this:
Image
(Click image for larger version.)
The code was "lifted" from this page; http://peak5390.wordpress.com/2012/12/08/matplotlib-basemap-tutorial-making-a-simple-map/
and just some small adjustments of the coordinates and color codes were made to make "your" map.
Chime back if you want the SVG file to "play" with. It's too big to upload to the forum.
The "detail level" can be adjusted in the code to make the file smaller.

Have Fun.
RGDS
Ragnar
Good Luck!
( ͡° ͜ʖ ͡°)
RGDS
Ragnar


Return to “Help with using Inkscape”