# River tracing

Hello.

Recently I’ve made a program, which allows to process satellite images (Bing and TMS are supported now) to create waterway objects - RiverTrace. Maybe it can be useful for someone.

To make it work, you need to specify two points: first defines the start of the way, second - the direction:

At first launch, program will create configuration file, which you can edit to fine-tune the algorithm parameters.

The program is intended to be invoked via JOSM, with the help of ext_tools plugin.
In “Ext Tools” settings three commands are need to be set:

Name: RiverTrace (1 param)
CmdLine: path\to\program\RiverTrace.exe lat1 {lat} lon1 {lon}
Description: Sets the first point
2.
Name: RiverTrace (2 param + go)
CmdLine: path\to\program\RiverTrace.exe lat2 {lat} lon2 {lon} go
Description: Sets the second point, starts a trace
3.
Name: RiverTrace (go)
CmdLine: path\to\program\RiverTrace.exe go
Description: Starts a trace with predefined parameters

Then the hotkeys needs to be bound to this commands (for example, “U”, “I” and “O”) via JOSM preferences.

At the first time it is enough to call the “go” command, the program will create the object with default parameters.

The quality of the result heavily depends on the quality of source images, especially on the contrast level between water and non-water.

Screenshots:

(My English skill is not the best, sorry for this)

That looks interesting, I’ll try it.
Do I need the latest version of JOSM, or may I still use an older version? How many pixels wide must a river be for tracing?

Thanks.

If your version can run ext_tools, then it is enough.
But as this program is written in C#, you also need .NET Framework installed (at this time program targets .NET 4.5, it is installed by default with Windows 8 and higher, with Windows 7 you need to install it manually). If the compatiblity becomes a problem, I will think about it.

Most likely, 3-4 pixels is a minimum.
Maximum is hardcoded at 100 pixels (you can pick lower zoom if you hit this limit).

How to compile under Linux? I’ve tried with MonoDevelop, but it lacks Presentation Core (says System.Windows.Media.Imaging is missing).

I did not tried to compile it with Linux tools.
But this is not a problem, since Windows-compiled versions also runs fine.
Here is the binary with Linux support:

If you still want to compile it in Linux, try removing “if (Type.GetType(“Mono.Runtime”) == null)” branches from SimpleBitmap.cs.

However, in Linux this program have lower processing accuracy because of bug in Mono.

In version 0.0.6 TMS support was added.

With high-quality images it is possible to trace rivers even with 1-pixel width:

Interested to try this program.
Can it be installed on Mac OS X 10.11.6 (El Capitan)

nevw, Mac OS should support running programs via Mono.
But because of bug, program results will have lower quality.

Vort, Can Rivertrace be used on the new MapBox DigitalGlobe Standard imagery or other imagery.
I notice the following in the config file…

 "imageSourceName": "Bing",
"imageSourceProtocol": "bing",
"imageSourceUrl": ""


so is this change all that is required…
“imageSourceName”: “MapBox DigitalGlobe Standard”,
“imageSourceProtocol”: “tms”,
“imageSourceUrl”: “http://{switch:a,b,c}.tiles.mapbox.com/v4/digitalglobe.0a8e44ba/{zoom}/{x}/{y}.png?”

Imac El Capitan 10.11.6, mono 4.6.2, Josm 12039

Yes, I use this lines:

  "imageSourceName": "DigitalGlobe Standard",
"imageSourceProtocol": "tms",
"imageSourceUrl": "http://{switch:a,b,c}.tiles.mapbox.com/v4/digitalglobe.0a8e44ba/{zoom}/{x}/{y}.png?access_token=pk.eyJ1IjoiZGlnaXRhbGdsb2JlIiwiYSI6ImNqMmFxcGJ2MjAwOHEzMm9nZmF2c3luZWkifQ.HsF19zOlj8PeOxo5BhNqyQ"