0

Hello every one, Just recently started getting acquainted with OSM. I have used the Map function in the python module osmapi to download a bounding box. My code is as follows:

from osmapi import OsmApi
myApi = OsmApi()  
bbox = myApi.Map(88.5052,23.4966,88.9680,23.8513)

I now want to get the list of ways inside this bounding box using python code. Is this possible? If so, would any one be so kind as to give pointers on how to go about doing so?

Thank you

asked 15 Mar '17, 16:29

imonike's gravatar image

imonike
963410
accept rate: 100%

edited 25 Mar '17, 09:33

aseerel4c26's gravatar image

aseerel4c26 ♦
32.2k16239552


One Answer:
1

You shouldn't use that module if you just want to fetch data, it accesses an API intended for editing.

Take a look at the Overpass module for accessing data:

https://github.com/mvexel/overpass-api-python-wrapper

Or maybe OSMAlchemy:

https://pypi.python.org/pypi/OSMAlchemy/

I like to just write an Overpass script and embed that rather than using a wrapper.

If you do intend to do programmatic editing, consider modifying the data using a script and then using JOSM to interact with the API (and be aware of the policy on automatic edits: http://wiki.openstreetmap.org/wiki/Automated_edits ).

permanent link

answered 15 Mar '17, 17:07

maxerickson's gravatar image

maxerickson
11.4k1075161
accept rate: 30%

Thanks so much maxerickson. I have come across the Overpass API, I guess it is time to dig in!! OSMAlchemy looks interesting. I still have a question, please don't be offended, it is really getting at my curiosity. Now the Map function I mentioned returns a list of dict objects that representing the nodes in the bounding longitudes and latitudes specified. If ways are a collection of nodes, isn't possible to get the list of ways I am looking for from the data I downloaded with the Map function?

Thank you for your patience.

(16 Mar '17, 14:53) imonike

I don't know the module. According to http://osmapi.metaodi.ch/#osmapi.OsmApi.OsmApi.Map the ways should be in the same dict.

(16 Mar '17, 17:41) maxerickson

Thanks maxerickson. I really appreciate. I have visited that page. It's where I learnt about the Map function. Here is a fragment of the data returned:[{u'data': {u'changeset': 45126331, u'uid': 4384747, u'timestamp': datetime.datetime(2017, 1, 13, 7, 55, 35), u'lon': 88.5834267, u'visible': True, u'version': 3, u'user': u'\u30aa\u30c1\u30a2\u30a4\u30b3\u30e9\u30dc', u'lat': 23.806732, u'tag': {u'source': u'AND'}, u'id': 245716849}, u'type': u'node'},--I guess that would represent a single node. There are similar nodes in dict form making up a list. There doesn't seem to be anything to let u know which nodes make up a way. Tried using the NodeWays method but my conn was forcibly closed by the host. Guess my code was violating their download rules. Anyway started looking at the Overpass API. Many thanks for the help. Cheers

(17 Mar '17, 13:40) imonike

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×246
×144
×53
×24
×5

question asked: 15 Mar '17, 16:29

question was seen: 2,634 times

last updated: 25 Mar '17, 09:33

powered by OSQA