You are not logged in.
- Topics: Active | Unanswered
Announcement
Please create new topics on the new site at community.openstreetmap.org. We expect the migration of data will take a few weeks, you can follow its progress here.***
Pages: 1
#1 2008-10-07 11:07:48
- FJDL
- Member
- Registered: 2008-10-07
- Posts: 4
Exporting list of street names
Hi there,
I'm trying to get a list of all the streets in the US by name. I checked the geonames data dump and it didn't appear to have any streets in the file, just lots of other types of places. Is there any way to export a list of streets from OSM in XML (or any format, really)?
Offline
#2 2008-10-07 11:34:39
- emj
- Member
- From: .se (59.3N17.99E) 0735969076
- Registered: 2006-06-18
- Posts: 949
Re: Exporting list of street names
Not off the shelf. You can get the whole world from: planet.osm that's an xml you can filter that.. Going to take you a while.
Or you can use OSMXAPI and request all highway=* ways. Going to take even longer I think.
Offline
#3 2008-10-07 12:14:41
- FJDL
- Member
- Registered: 2008-10-07
- Posts: 4
Re: Exporting list of street names
Thanks for the response - any suggestions on how to filter the XML file? (I can't actually view the structure because I downloaded just the Wyoming file and it was 830 MB, too big to open up directly...)
Offline
#4 2008-10-08 15:00:09
- emj
- Member
- From: .se (59.3N17.99E) 0735969076
- Registered: 2006-06-18
- Posts: 949
Re: Exporting list of street names
First I want to ask if you really just want to have a list of the names?
Second I'll say I haven't solved this for you but I can give you some experimenting that I did with XSL:s, these can extract names from XML pretty easily, but it might be slow on a 900MB file....
First rename the uncompressed Openstreetmap data file as "map.osm", then open render.xml in a browser or as described in the Osmarender howto.
style.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="data" select="document('map.osm')"/>
<xsl:template match="/">
<html>
<h2>All Ways with names</h2>
<table><tr><th align="left">name</th><th>way id</th></tr>
<xsl:for-each select="$data/osm/way/tag[@k='name']">
<tr>
<td><xsl:value-of select="@v"/></td>
<td><xsl:value-of select="../@id"/></td>
</tr>
</xsl:for-each>
</table>
</html>
</xsl:template>
</xsl:stylesheet>
render.xml
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="style.xsl"?>
<dummyworthlesstag/>
Misc examples
All these examples require that you save the code as "style.xsl" and then a stylesheet xml tag to the osm file. like this:
<?xml-stylesheet type="text/xsl" href="style.xsl"?>All ways that have a name, with way id:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/osm">
<html>
<h2>All ways with names</h2>
<table><tr><th align="left">name</th><th>way id</th></tr>
<xsl:for-each select="way/tag[@k='name']">
<tr>
<td><xsl:value-of select="@v"/></td>
<td><xsl:value-of select="../@id"/></td>
</tr>
</xsl:for-each>
</table>
</html>
</xsl:template>
</xsl:stylesheet>All ways and all their tags
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>All the Ways and their tags.</h2>
<table border="0">
<tr bgcolor="#9acd32">
<th align="left">way id</th>
<th align="left">way tags</th>
</tr>
<xsl:for-each select="osm/way">
<tr><td> <xsl:value-of select="@id"/> </td>
<td>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">key</th>
<th align="left">value</th>
</tr>
<xsl:for-each select="tag">
<tr>
<td><xsl:value-of select="@k"/></td>
<td><xsl:value-of select="@v"/></td>
</tr>
</xsl:for-each>
</table>
</td></tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>All ways and names on the ones that have one
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>All ways and names on the ones that have one</h2>
<table border="0">
<tr bgcolor="#9acd32">
<th align="left">way id</th>
<th align="left">name</th>
</tr>
<xsl:for-each select="osm/way">
<tr><td> <xsl:value-of select="@id"/> </td>
<td>
<xsl:for-each select="tag[@k='name']">
<td><xsl:value-of select="@v"/></td>
</xsl:for-each>
</td></tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>Last edited by emj (2008-10-08 15:06:05)
Offline
#5 2008-10-08 16:03:19
- Skywave
- Member
- Registered: 2007-11-13
- Posts: 91
Re: Exporting list of street names
Also it would be possible to extract a list from pgsql, import the data with osm2pgsql then this
psql gis
select name from planet_osm_line where name is not null;
Offline
#6 2008-10-08 19:19:31
- emj
- Member
- From: .se (59.3N17.99E) 0735969076
- Registered: 2006-06-18
- Posts: 949
Re: Exporting list of street names
Yes that is simpler, can you get a position or a bounding box for those ways that as well? But actually it would be possible from XAPI as well. Just do a [name=*] in the download parameter.
Offline
#7 2008-10-18 07:18:50
- FJDL
- Member
- Registered: 2008-10-07
- Posts: 4
Re: Exporting list of street names
Hmm...I tried both methods above, but render.xml just rendered completely blank, and I can't seem to get PostgreSQL up and running to use osm2pgsql without an error. Are there any other methods you guys know of to get this data into a usable format?
Offline
#8 2008-10-18 13:08:40
- JRA
- Member
- Registered: 2007-12-17
- Posts: 677
Re: Exporting list of street names
What error do you get from PostGIS? I think that getting data into PostGIS could be very good alternative for you. Not only could you select all names of the highways (select name from planet_osm_line where name is not null and highway is not null), but you could also sort the results by places (is_in), highway classes etc.
Offline
#9 2008-10-20 13:55:33
- emj
- Member
- From: .se (59.3N17.99E) 0735969076
- Registered: 2006-06-18
- Posts: 949
Re: Exporting list of street names
I used ubuntu 8.04, installed postgres 8.3 with postgis extensions installed (which I had to do add in a config). After some trial and error it worked.. :-) So if you post us the error messages, I'm sure someone can helpt you.
Offline
#10 2008-10-21 12:30:56
- FJDL
- Member
- Registered: 2008-10-07
- Posts: 4
Re: Exporting list of street names
Unfortunately, I'm running all this on windows, which seems to lack documentation. In pgAdmin I can see that I have a running server on localhost, with the postgis database properly configured. The error I get is:
"Using projection SRS 3395 <WGS84 Mercator>
Setting up table: planet_osm_point
Connection to database failed: fe_sendauth: no password supplied"
I have a pgpass.conf file set up, which, from the few posts I could find about this problem, is supposed to solve it, but it doesn't. As far as I can tell, there's no way to set the password in flags for osm2pgsql. Any ideas?
Offline
#11 2008-10-21 17:54:15
- Skywave
- Member
- Registered: 2007-11-13
- Posts: 91
Re: Exporting list of street names
according to this page http://manpages.ubuntu.com/manpages/int … pgsql.html -W should force a password prompt.
Offline
#12 2008-10-21 20:06:39
- JRA
- Member
- Registered: 2007-12-17
- Posts: 677
Re: Exporting list of street names
Hi,
It is in the server settings, in file pg_hba.conf. That must be set to use method "trust". Windows version on osm2pgsql does not give any way to give username and password. Therefore you must create a user with the same name as you are logged in to Windows, and set database so that it does not ask password at all. This same information is in http://wiki.openstreetmap.org/index.php/User_talk:JRA.
I believe that nobody is going to update or improve osm2pgsql.exe for us Windows users without getting paid for it. I am ready to invest some money for the development. I fear that after new API 0.6 comes I will be without PostGIS updates.
Offline
#13 2008-10-23 07:47:03
- emj
- Member
- From: .se (59.3N17.99E) 0735969076
- Registered: 2006-06-18
- Posts: 949
Re: Exporting list of street names
osm2pgsql.exe for us Windows users without getting paid for it.
I can only find one ticket in trac concerning Windows. So: Identify the problems, and possible solutions and people might help you out.
Offline
Pages: 1