1

Consider the following SVG of a globe:

Vector image of a globe, centered on the Atlantic

Apart from the inland waters and the latitude/longitude lines, which are not relevant to this question, the SVG is constructed from three shapes: A black object for the oceans, a blue square, and a green circle:

Diagram showing the aforementioned black object, blue square, and green circle

The blue square is placed behind the black object and clipped, and the result is then placed over the green circle.

I would like to add a black border around the oceanic coastline. The border should extend into the ocean, not into the land. This is effectively stroking the inverse of the clipped object. That is, I'd like to end up with something like the following:

The same globe, with the coastline outlined in black

How can I do this in Inkscape?

Similar questions on this site and others propose solutions that involve converting the object to a path, but for some reason the "Object to Path" command doesn't work on the black object.

  • Is it an image? Or perhaps it is a bath already. – joojaa Jan 1 '18 at 13:00
  • @joojaa: The black shape is not a bitmap. From reading the SVG source, it does seem to be a path, but Inkscape 0.92 isn't treating it as such. (For example, none of the commands in the Path menu seem to have any effect on it, and the "Edit paths by nodes" tool shows no nodes.) – Psychonaut Jan 1 '18 at 13:27
  • Well i dont have a problem with this i just assign the green ones a black outline, and offset it by half a stroke. But you may want to expand the clipping mask, copy it and re apply it then use the copy as a stroke source. – joojaa Jan 1 '18 at 14:14
  • How can you "assign the green ones a black outline"? The green part of the image is just a circle with a gradient fill, which is visible only through the clipped blue square. Setting the stroke on it will only put a border around the circumference of the globe. If you're able to reproduce my mockup image in Inkscape, please post step-by-step instructions as an answer and I will accept it. – Psychonaut Jan 1 '18 at 14:43
4

I downloaded the SVG to examine it.

The black object is a clone. That's why you can't edit it properly.

An easy way to find out if an object is a clone is to examine it in the XML editor in Inkscape. If you see the selected item is showing something like <svg:use id="use1234">, then that means it's a clone. A normal path looks like this <svg:path id="path1234">

To turn it back into an ordinary path, select it and click Edit > Clone > Unlink Clone. Then you can copy it, revert the SVG to the original, then paste back the copy, align it, set the fill to none, set the stroke to whatever you want. Change the stack order so it's under the grid lines.

Here's the SVG with a black outline added, using the above technique.

  • Thanks for the explanation of the cloning issue! I tried doing what you said and was able to stroke the object. However, this makes the border go into the land, not into the ocean. (BTW, the link to your SVG doesn't work for me. It takes me to a web page full of ads for the file hosting service, but no actual file.) – Psychonaut Jan 1 '18 at 21:15
2

I downloaded the SVG and noticed: The oceans are masked with the back shape that does not allow path operations. The following succeeded:

  • ungrouping
  • hiding the latitudes and longitudes away
  • changing the land areas to single solid color
  • filling with paint bucket the land areas to get them as Inkscape paths
  • adding stroke to the land areas
  • removing possible unwanted stroke sections
  • making the stroke to path (=coastline path)
  • subtracting the land areas from the coastline path
  • coloring the rest of the coastline path to black

Here's a screenshot of the partially filled land areas (=orange) and all path nodes visible:

enter image description here

Here's tested to make the coastline path. The land areas are just subtracted, so the coastline path is only on the sea. No part in the edge and lakes is removed, small islands were skipped

enter image description here

No need to paint the land areas. As well you can paint the oceans. The coastline path on the sea is achieved by making an intersection with the full coastline path and strokeless sea area.

Here's another fill example. Atlantic and Pacific areas were filled with red and got black strokes. Then an union was made as path operation:

enter image description here

The path was duplicated, stroke was removed from upper copy, fill from lower copy, the stroke was converted to a path (=the full coastline path) and the strokeless ocean was intesected with the coastline path. No tinkering with islands were needed:

enter image description here

The black strokes at the edges are probably unwanted. They should be removed just before conversion to path. Selection of multiple stroke segments for conversion is easy in objects panel or as well by the same color in Edit menu.

To keep all placed properly have a hidden copies of the original shapes. Finally you want only to take the coastline path and place it under the latitudes and longitudes in the object panel.

Stop press and at least upvoting! The result is good onscreen, but high zoom reveals the inaccuracy. Paint bucket doesn't create complex enough path for this!

  • This seems to work but your fourth step ("filling with paint bucket the land areas") involves a lot of tedious manual selection for the islands, of which there are several dozen in the image. I would prefer a solution that handled these automatically. – Psychonaut Jan 1 '18 at 15:39
  • @Psychonaut the story is now completed. – user287001 Jan 1 '18 at 17:17
  • @Psychonaut I watched my results in high zoom. It revealed here and there poor accuracy. The paint bucket simply doesnt't create complex enough path. => This method isn't probably the one you want. I must remove it because it can fool someone to believe it. – user287001 Jan 1 '18 at 22:13
  • It was an admirable effort! With a hint from Billy Kerr's answer, I was able to come up with a method that does not rely on the Paint Bucket Tool. I reference your answer in mine, so I think it's fine to leave yours up. (Your method might be fine for simpler shapes.) – Psychonaut Jan 1 '18 at 22:23
2

Once Billy Kerr explained that the black shape is a clone, it became easy to adapt existing answers to solve this problem:

  1. Select the black shape and unlink it (Edit→Clone→Unlink Clone) to get the original object.
  2. Convert the object to a path (Path→Object to Path).
  3. Copy the path (Edit→Copy).
  4. Draw a rectangle with a stroke but no fill around the path.
  5. Select the rectangle and the path and combine them (Path→Combine). The path will change to an outline.
  6. Using the Edit Paths by Nodes tool, edit the new path to remove the rectangle and the path segments around the circumference of the globe. (There's only a few.)
  7. Paste the path (Edit→Paste) and align it overtop the outline version.
  8. Select both paths and clip (Object→Clip→Set). This ensures the stroke extends only into the ocean, not into the land.
  9. Copy the path, paste it on the original image, and lower it so that it is just below the latitude/longitude lines.

enter image description here

This method has the advantage over the one posted by user287001 that it does not rely on the Paint Bucket Tool, which is a glorified bitmap tracer. The fidelity of all paths is therefore preserved.

  • Glad it got you to where you wanted to go. – Billy Kerr Jan 2 '18 at 0:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.