How can I create a way with exact [x] meters in JOSM?

Short version of what I want:

  • Create a way with precisely x meters.
  • Snap to full meters when drawing a way.

Long version:

Hello, I already searched on the forum and on other places but did not find an answer to my question. Maybe I used the wrong key words for my search.

I was wondering if there is a plugin or a build in function in JOSM to easily create a way with a specific length. Eg. 5 meters.

I know that I can check the length of the way I’m drawing in the measurement bar at the bottom in the field The length of the new way segment being drawn. But this is not very precise and a slow process as you have to do it in a free hand way and need to zoom in quite a lot to get the specific 5 m and not 5.04 meters.
So is there a way of starting to draw the way and inputting the desired length with the keyboard or turning on a snapping mode where ways get created only at rounded up meters?

Thanks for your help!


I am not aware of an action or a plugin providing that function. Feel free to create a ticket at JOSM trac using the “Report bug” action under the help menu.

Meanwhile, you could use the parallel mode for helper lines. In advanced preferences you can set the snap distances for this mode.

1 Like

you could make one long way with the “total” length, and then add as many nodes as you need and distribute them evenly (shift+b), but this probably requires you to work with a straight line. I guess you COULD do similar things for arcs and cricles (if you maths is strong) since they are autodistributed when the arc or circle is created.

1 Like

Hi @SekeRob,
that’s unfortunately not what I meant. The Simplify Way option is for removing unnecessary nodes for an already created object. But I want to create a new object with precise lengths.

In the picture you can see that I activated angle snapping to get a 90° angle. The field The angle between the previous and the current way sement. is marked green to show that I’m in the angle snapping mode. The field to the right The length of the new way segment being drawn shows 4.99 m but that’s what i want to be in some type of length snapping mode to get easily and fast the 5 m I want.

also, you can create them externally. If you can convert coordinates to meters you can just make an .osm file and open it in JOSM. I dont know how exact you need to be here :smiley:

1 Like

Here is a script that will creat a way in the center of your screen of a specified length in meters. You can then rotate it and move it around as needed. As long as you stay in the immediate area, the length, as reported by JOSM, will be accurate. You will need the scripting plugin in order to run this.

from import LatLon
from import Node;
from import Way;
from org.openstreetmap.josm.gui import MainApplication
from javax.swing import JOptionPane
earth_circumference = 40075017.0
length = float(JOptionPane.showInputDialog("Length of way:"))
# Get the center of the screen
scrn_ctr = MainApplication.getMap().mapView.getRealBounds().getCenter()
# Make the starting node
st_node = Node(scrn_ctr)
activeDataSet = MainApplication.getLayerManager().getActiveDataSet()
end_lat = + (length / earth_circumference) * 360
end_lat_lon = LatLon(end_lat, scrn_ctr.lon())
end_node = Node(end_lat_lon)
new_way = Way()

Note that the distance is not survey quality (but the measurements in JOSM are not either).

This is going to be a bit more challenging…

There a simplify way option to reduce the node interval to a certain distance, an in arrears so to speak