This is the P2PU Archive. If you want the current site, go to www.p2pu.org!

Online Maps with OpenLayers

My recent threads

You haven't posted any discussions yet.

Recently updated threads

OSM API mapping

Go back to: General discussion

Hi class members,

I would appreciate your help in the following:

Say, I have data of some youth resources that I want to put in OSM. What would be the simplest way (by using API 0.6) to map this data (data means: name of resource, latitutde and longitude).

Thanks in advance and thank you also for all the good materials, guides and answers in this class

nori

Nick Doiron's picture
Nick Doiron
Wed, 2011-04-06 18:12

If none of these points are mapped already, your goal should be a script that creates each point using HTTP PUT method to /api/0.6/node/create

http://wiki.openstreetmap.org/wiki/API_v0.6#Create:_PUT_.2Fapi.2F0.6.2F....

Some background for people not familiar with HTTP: when you type in a URL, your browser sends a GET request to that server; when you're sending a form you often use POST to separate a URL and some data. PUT is similar to POST, and is used for cases where a new page is created (in this case, the new point's reference page on OSM).

The data that you want to attach is in OSM's XML format. If you're not sure how to format it, you can download some data from OSM as an example. This is a point at 35 S, 55 W which will appear as a school:

<osm>
<node changeset="12" lat="-35" lon="-55">
<tag k="amenity" v="school"/>
<tag k="name" v="Sample School"/>
</node>
</osm>

I don't know what scripts you've made before, but here is an example of a PUT request in Python: http://stackoverflow.com/questions/111945/is-there-any-way-to-do-http-pu...

Nick Doiron's picture
Nick Doiron
Wed, 2011-04-06 18:14

Actually this is more complicated than I thought. You have to open a new changeset, and put its number into the changeset="__" part of the request. You also need to be authenticated (username and password) for each step. Then you close the changeset.

nori nh's picture
nori nh
Thu, 2011-04-07 16:57

Thanks Nick,

Yes, I was thinking along similar line by downloading OSM file of my country and adding new nodes in it. The problem is that I am not sure what the value of changeset should be and moreover the id of a node.

As far as changeset is concerned, as I am reading here http://wiki.openstreetmap.org/wiki/API_v0.6#Changesets_2, as you say, one has to open a changeset online and then use that ID for all the nodes that will be added to the osm xml file!

But, for the node ID - I guess there must be some way to know the latest used ID in OSM db for a particular region or country and then simply increment for each inserted node!

I hope that someone who has done this before will reply.

Thanks