User:EMKLI/Create realistically looking lakes or islands: Difference between revisions

From OpenGeofiction
(Create the first draft, still without pictures)
 
m (Some additions in the search and import section.)
Line 2: Line 2:


I would like to show you a method that I used for creating the lake landscape in Nordurland. It will allow you to create lots of these items at once, in a relatively fast manner.
I would like to show you a method that I used for creating the lake landscape in Nordurland. It will allow you to create lots of these items at once, in a relatively fast manner.


Please note: This tutorial is still missing pictures. I will add them in the subsequent days.
Please note: This tutorial is still missing pictures. I will add them in the subsequent days.
Line 10: Line 9:
*A screenshot tool
*A screenshot tool
*JOSM with the importvec plugin installed
*JOSM with the importvec plugin installed
*Optional: a bitmap editing software. It can be as simple as M$ Paint.
*A vector editing software. For the tutorial, I used Inkscape. The way to do things may vary in other softwares.
*A vector editing software. For the tutorial, I used Inkscape. The way to do things may vary in other softwares.
*An image file that contains "patchy" data.
*An image file that contains "patchy" data.
Line 15: Line 15:


Regarding the last point, although I have written that you can create results relatively quickly, this process is still pretty long, tedious and requires a lot of manual work. Do not expect quick satisfying results, especially not at the first try. It will take time. Think in multilpes of hours, not minutes.
Regarding the last point, although I have written that you can create results relatively quickly, this process is still pretty long, tedious and requires a lot of manual work. Do not expect quick satisfying results, especially not at the first try. It will take time. Think in multilpes of hours, not minutes.


For the sake of this tutorial, I am assuming that we are going to create lakes and islands, so I will use the terminology accordingly. But you can create all sorts of random-looking structures with that, like patchy forests, swamps, ...
For the sake of this tutorial, I am assuming that we are going to create lakes and islands, so I will use the terminology accordingly. But you can create all sorts of random-looking structures with that, like patchy forests, swamps, ...
Line 32: Line 31:
== Search and import ==
== Search and import ==


The first taskis to find a source for one - or better - multiple images. A good source is weather data, especially clouds and precipitation. They often create random-looking shapes in sequential order. '''Please be aware that you are using someone's data here. You are obliged to check if the distributor allows the use of the data for non-commercial purposes.'''
=== Search for an image ===
For this example, I used [https://www.wunderground.com/wundermap Wundermap]. For getting nice results, I chose the radar and satellite layer (which gives you cloud and rain data) and set opacity for both to 100%. Also, I chose an area about the open ocean, because this reduces borders, names and other features that I don't want to have in the picture.
Find a good spot that contains many patchy objects, then, take and save your screenshot.


The first taskis to find a source for one - or better - multiple images. A good source is weather data, especially clouds and precipitation. They often create random-looking shapes in sequential order.
Optional: If you already know that there are parts in your image that ar not suitable for vectorizing, I recommend to paint over them before you import your picture to Inkscape in the next step. You can use any bitmap editing software for that. Problematic parts are any letters and designations, borders as well as parts of landmasses.


=== Search for an image ===
In your paint program, you can simply white out any landmasses at the borders of your image. For text or borders in the picture, I recommend using the surrounding color.
For this example, I used [https://www.wunderground.com/wundermap Wundermap]. For getting nice results, I chose the radar and satellite layer and set opacity for both to 100%. Also, I chose an area about the open ocean, because this reduces borders, names and other features that I don't want to have in the picture.


If you found a good spot, take and save your screenshot.


=== Vectorize the image ===
=== Vectorize the image ===

Revision as of 09:40, 14 April 2023

Creating random-looking formations like lakes, wood patches or islands is not an easy task. First of all, if you create many of them manually, they often don't really look "natural" or "fractalized" enough. Also, it is a lot of work.

I would like to show you a method that I used for creating the lake landscape in Nordurland. It will allow you to create lots of these items at once, in a relatively fast manner.

Please note: This tutorial is still missing pictures. I will add them in the subsequent days.

What you need

  • A screenshot tool
  • JOSM with the importvec plugin installed
  • Optional: a bitmap editing software. It can be as simple as M$ Paint.
  • A vector editing software. For the tutorial, I used Inkscape. The way to do things may vary in other softwares.
  • An image file that contains "patchy" data.
  • A lot of patience.

Regarding the last point, although I have written that you can create results relatively quickly, this process is still pretty long, tedious and requires a lot of manual work. Do not expect quick satisfying results, especially not at the first try. It will take time. Think in multilpes of hours, not minutes.

For the sake of this tutorial, I am assuming that we are going to create lakes and islands, so I will use the terminology accordingly. But you can create all sorts of random-looking structures with that, like patchy forests, swamps, ...

What we will do

  • search for an image that satisfies our needs
  • load that picture as bitmap into Inkscape
  • trace the bitmap in Inkscape to vectorize it
  • check the results and choose the paths you want to use
  • arrange your paths to create the landscape in Inkscape
  • save the result as svg and import that file into JOSM
  • clean up import errors and tag in JOSM
  • upload your creation and check for coastline errors

Search and import

The first taskis to find a source for one - or better - multiple images. A good source is weather data, especially clouds and precipitation. They often create random-looking shapes in sequential order. Please be aware that you are using someone's data here. You are obliged to check if the distributor allows the use of the data for non-commercial purposes.

Search for an image

For this example, I used Wundermap. For getting nice results, I chose the radar and satellite layer (which gives you cloud and rain data) and set opacity for both to 100%. Also, I chose an area about the open ocean, because this reduces borders, names and other features that I don't want to have in the picture.

Find a good spot that contains many patchy objects, then, take and save your screenshot.

Optional: If you already know that there are parts in your image that ar not suitable for vectorizing, I recommend to paint over them before you import your picture to Inkscape in the next step. You can use any bitmap editing software for that. Problematic parts are any letters and designations, borders as well as parts of landmasses.

In your paint program, you can simply white out any landmasses at the borders of your image. For text or borders in the picture, I recommend using the surrounding color.


Vectorize the image

When you've found your picture, it is time to open and trace it in Inkscape.

  • In Inkscape, select File -> Import to load the image you've just saved. Go with the default settings, you will delete the original image anyway
  • Select the imported image and choose Path -> Trace bitmap from the menu bar.
  • I usually go with the following configuration, but you can try out any other that suits your needs.
    • Select Multicolor. Choose Colors or Grays as Detection mode. Check Stack and Remove background.
    • Choose the number of scans that is equal to the number of features in your map (i.e. the number of colors that occur in the image). Check the results in the preview.
    • Optionally, play with the other (slider) values as well. You can't techincally go wrong here, it is a matter of personal taste.
  • Click Apply when you are finished and give the program some time for the tracing. You get a group of layers with (probably) multiple paths, each representing the layers Inkscape found in the picture.
  • You can repeat the process and import and trace multiple images at once.

Getting creative

This is the fun part. You will now extract the elements of a (hopefully) big amount of shapes you've just got.

Select the data you want

  • You can begin with ungrouping the layers with Object -> Ungroup. This sets all traced layers free to move individually.
  • If you have multiple paths in a layer, you can use Path -> Break Apart to separate them.
  • Beware: you may find smaller shapes hidden beneath bigger ones. This can be in your favor if you want to have lakes with little islands inside - or not. Just a heads-up. Move around bigger shapes to see what's behind them.
  • If a layer of data does not look promising at the first glance, you may try to invert it. For that, enable snapping in Inkscape (it is disabled by default) with the magnet button at the very top right. Then, draw a rectangle with the exact dimensions of your layer. Then, choose Path -> Exclusion from the menu bar.
  • Still, not all the data you've created may be useful to you. Delete as many paths if you need to. Also, you can always go back and try to get a better image.

Create your landscape in Inkscape

Now, you can freely arrange the shapes you've just got. Some tips to deal with the data.

  • If you want to merge multiple items, select them and choose Path -> Union.
  • If you find your edges too smooth, try to apply the Roughen path effect. Select Path -> Path effects. On the right, click to "+" and select the Roughen effect. Go not too crazy with it though as it may create lots of self-interecting lines in JOSM later.
  • Move, adjust, deform and arrange your lakes or island shapes as desired.

Export your result

When you are satisfied with your creation, we have to do some cleanup to get the data as lean and clean as possible into JOSM. The more we clean here, the easier the import gets. From my experience, the SVG import to JOSM is a bit unstable.

  • When you are ready to export, make sure you've deleted everything you don't want to include in the final result.
  • Overall, don't go too crazy with the amount of things. Importing an SVG to JOSM is not a fast process and can render it unstable.
  • Select everything in your document that you want to export and select Path -> Simplify. This is important. If you don't to it, the import into JOSM will take forever. Do not forget this step, especially if you have many items in your drawing!
  • Save the image as SVG.

Transferring to OGF

Now it is finally time to make your creation into a map. but before that, we have to clean the data... again. This time, in JOSM.

Import to JOSM

A word of warning: the import to JOSM is somewhat unstable and it takes a lot of time.

In JOSM, sure you have the importvec plugin enabled.

  • Before you begin, upload all changes that are still pending and remove all unnecessary layers.
  • Create a new layer. Do not use any existing layer.
  • Click File -> Open and select the file you've just created with Inkscape
  • Here, I encounter a little bug because a window with a progress bar pops up that never closes again. I am only able to kill it with the X button, (not the cancel button).
  • A small window will pop up. Here, you can change the scale of the imported data. I normally go with a scale of 1:50 or 1:100, but it depends on your desired scale, of course. Try some things out.
  • For the edge factor, I would not go higher than the default 4. I'm not sure if it has any effect on the data at all, but we've just reduced the amount of nodes in Inkscape, so we should not add them again here.

Now, brew yourself a huge can of coffee. Importing can take a lot(!) of time. You may see some progress in your map window while the import takes place -not in the little window with the progress bar though, the progress here will always be 0%. More and more empty nodes will appear over time and they will eventually be connected with nodes in the end. But the process is slow.

If you have the feeling that nothing happens anymore, you have no other choice than killing JOSM altogether. If this happens, you've tried to import more data than JOSM can take. In this case, go back to Inkscape and divide your image in two or more separate files. Upload each of these files separately.

Prepare the data for upload

Your data is now in JOSM, but if you think you are ready, think again. Now the biggest part of the work starts. Because you've just imported hundreds or thousands of nodes into JOSM, and the data is not necessarily clean. You may have overlapping paths, islands in lakes (like I've said before, there may be paths hidden below other paths which might not be visible in Inkscape), self-intersecting paths, double nodes and open polygons.

Also, your data may contain lots of polygons with only 3 or 4 nodes, or some that are really small. Think thoroughly if they really are a valuable addition to the map. You should either edit them later on (or better: right away) or delete them altogether. You will find a tip how to quickly search for and select them below.

In my experience, preparing the data for upload is the part that takes the most time. Patience and a strong machine are the key here. Make excessive use of the error checking function and save as often as possible. I would reccomend the following steps in this exact order:

  • First, check for erros. You can autocorrect most double nodes.
  • Clean the errors as much as possible.
  • If you want to merge overlapping polygons, use Shift + J to join them.
  • Check for very small polygons as you may want to delete them. For that, use the search filter.
    • For example, if you want to delete polygons with a low node count, you can use a filter: type: way & nodes: 0-4 will select all nodes with a maximum count of 4 nodes
    • You could also define a certain area: type: way & areasize: 0-5 would select all polygons with an enclosed area of max. 5m².
  • Then, define your multipolygons. Tipp: there is an experimental function in the UltilsPlugin2 extension that allows you to select everything within a polygon. You find it under Select -> Select eyerything inside. It works for me but your results may vary. It also selects the nodes, so you still have to manually select polygons only.
  • If you have only one kind of thing you want to tag (lakes, in this example), it is now very easy to select all remeining untagged ways. Create a filter: type:way & untagged -child. This excludes your previously tagged multipolygons and you can't overlook small polygons.
  • If you created or edited new coastlines, check for any errors you've made. Be very thorough here. Better check twice.

Upload and second coastline check

If you think you are ready, upload your creation to the server. You are finally done! Unless...


If you have edited any coastlines, please allow the upload to complete, then wait for the next half hour to pass. After that, visit the coastline checker to check once more for coastline errors.

Yes, again. I really mean it. I recently had the problem that JSOM did not find all duplicate nodes and this inhibited the coastline rendering. So please, take this seriously. Correct any errors that you find and upload the corrections.