Making a changeset for a new way

Hi folks,

I am trying to make a changeset-file that adds a few nodes and a new way using these nodes. I am doing this in python, by first making a dictionary and then writing it to an xml-file using the xmltodict module. I have been able to make a simple way by connecting two existing nodes. I know this works since osrm routes along this new short-cut route. But when I try to add new nodes along that way the new way is ignored, so I must be doing something wrong. Here is the changeset with a new node in the middle of the new way.

<?xml version="1.0" encoding="utf-8"?>
<osmChange version="0.6" generator="acme osm editor">
        <create>
                <node id="10263105667" changeset="1" timestamp="2023-03-21T21:37:45Z" version="1" lat="10.659116000000001" lon="59.827652">
                <tag k="amenity" v="school"/>
                </node>
                <way id="1122147596" changeset="1" timestamp="2023-03-21T21:37:45Z" version="1">
                        <nd ref="8116323496"></nd>
                        <nd ref="10263105667"></nd>
                        <nd ref="8116345054"></nd>
                        <tag k="highway" v="primary"></tag>
                        <tag k="maxspeed" v="80"></tag>
                        <tag k="name" v="Snarveien"></tag>
                        <tag k="ref" v="159"></tag>
                        <tag k="surface" v="asphalt"></tag>
                </way>
        </create>
</osmChange>

I then use osmosis to generate an updated file:

osmosis --read-xml-change file=“changeset.xml” --read-pbf file=“norway-latest.osm.pbf” --apply-change --write-pbf file=“updated.osm.pbf” omitmetadata=true

Any glaring errors here?

What problem are you trying to solve that requires you to add new ways (or nodes to existing ways) in Python?

1 Like

I am not required to use python, just what I am most familiar with. It is for a project where we want to simulate the impact of new roads. It will be for internal use, so I to not intend to push these changes to the public map.

4 Likes

Hmm I’m surprised that creating new elements with “regular” ids works, but OK maybe osmosis ignores that they aren’t placeholders.

But if I understand you correctly you just want to add a new node to the already existing way? Then the way should be in a “modify” section, not in a “create” one.

I wanted to create a new way, with new nodes. It turns out what I had done was working, except I had switched lon/lat so the route was not very competitive! I have also changed to negative IDs as you suggested. Thanks for the input.

1 Like