You are not logged in.


*** NOTICE: By 30th of September 2022 the will be retired, please request a category for your community in the new ones as soon as possible using this process, which will allow you to propose your community moderators. We expect the migration of data will be finished by that date, you can follow its progress here.***

#1 2020-01-08 22:26:22

Registered: 2020-01-08
Posts: 2

How to update node in Python osmapi?

Hello. I would like to update OpenStreetMap with Python using osmapi module.

I wanted update name of node 6258337521 from value "Biblioteka Miejska w Łodzi Filia nr 63" to value "Biblioteka Miejska w Łodzi, Filia nr 63" (in English: "City Library in Lodz, Branch No. 63")

Below is IPython session:

In [1]: from osmapi import OsmApi

In [2]: myApi = OsmApi(username="jrk", password="********")

In [3]: myApi.ChangesetCreate({u"comment": u"Dodanie przecinka w nazwie"})

Out[3]: 79355591

In [4]: f63 = myApi.NodeGet('6258337521')

In [5]: f63

{'id': 6258337521,
 'visible': True,
 'version': 2,
 'changeset': 72857560,
 'timestamp': datetime.datetime(2019, 7, 31, 13, 39, 34),
 'user': 'BMwL',
 'uid': 9655269,
 'lat': 51.7672921,
 'lon': 19.4787142,
 'tag': {'addr:city': 'Łódź',
  'addr:country': 'PL',
  'addr:housenumber': '75',
  'addr:postcode': '90-031',
  'addr:street': 'Tuwima',
  'amenity': 'library',
  'contact:email': '',
  'contact:phone': '+48 42 674 48 73',
  'name': 'Biblioteka Miejska w Łodzi Filia nr 63',
  'operator': 'Biblioteka Miejska w Łodzi',
  'wheelchair': 'no'}}

In [6]: myApi.NodeUpdate({'id': 6258337521, 'lat': f63['lat'], 'lon': f63['lon'], 'version': f63['version'], 'tags': {'name': 'Biblioteka Miejska w Łodzi, Filia nr 63'} })

{'id': 6258337521,
 'lat': 51.7672921,
 'lon': 19.4787142,
 'version': 3,
 'tags': {'name': 'Biblioteka Miejska w Łodzi, Filia nr 63'},
 'changeset': 79355591}

In [7]: myApi.ChangesetClose()

Out[7]: 79355591

In [8]:

Changeset was saved, but unfortunately without my change. What did I do wrong?

Best regards,


#2 2020-01-09 01:53:17

Registered: 2020-01-08
Posts: 2

Re: How to update node in Python osmapi?

OK, I managed to find out how to do it. it was a typo, I wrote "tags" instead of "tag".

Here is the code that works:

from osmapi import OsmApi

myApi = OsmApi(username='jrk', password='********')

myApi.ChangesetCreate({'comment': 'Added opening_hours tag'})

node = myApi.NodeGet('6665468241')

tag = node['tag']
tag['opening_hours'] = 'Mo 11:00-15:00; We 09:00-14:00; Fr 11:00-15:00'
tag['opening_hours:url'] = ''

    'id': 6665468241,
    'lat': node['lat'],
    'lon': node['lon'],
    'version': node['version'],
    'tag': tag })



#3 2020-01-15 13:43:51

Registered: 2010-03-14
Posts: 2,193

Re: How to update node in Python osmapi?

Two remarks:

- when testing new applications -always- use the sandbox API when uploading ( … 52/8.40007) or install a rails-port instance locally.
- given there is really only one reason to do what you are doing: … of_conduct


Board footer

Powered by FluxBB