<div dir="ltr">Hi Jukka!<div><br></div><div>Thank you for the detailed instructions!</div><div><br></div><div>it took me a whole year to get this installed.<br></div><div><br></div><div>are you still doing mapping?</div><div>

<br></div><div>i wrote a number of scripts to parse pbf files for our charity maps for indonesia.  they are not very efficient.</div><div>

<br><br><div class="gmail_quote">On Sat, Sep 29, 2012 at 12:37 AM, Jukka Rahkonen <span dir="ltr"><<a href="mailto:jukka.rahkonen@latuviitta.fi" target="_blank">jukka.rahkonen@latuviitta.fi</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div>Alex Rollin <alex.rollin <at> <a href="http://gmail.com" target="_blank">gmail.com</a>> writes:<br>
<br>
><br>
><br>
> Hello,<br>
><br>
><br>
> I am rather new to OSM data.  I've enjoyed doing edits on the map and<br>
now I'd<br>
like to start learning how to arrange it on a printed page.<br>
><br>
> I know there are lots and lots of tools out there.<br>
><br>
><br>
> Could I receive a few recommendations for getting some text data out?<br>
><br>
> I was thinking I might need to use Osmosis.  Some pointers would be<br>
 very helpful.<br>
><br>
><br>
><br>
> I would like to:<br>
<br>
 Select a bounding box (I can produce lat/lon)<br>
 Get a list of street names'<br>
 Output a CSV file (or other text file)<br>
<br>
 Select a bounding box (I can produce lat/lon)<br>
 Get a list of POIs<br>
<br>
 Output a CSV file (or other text file)<br>
<br>
 For these I would also like to be able to get any other attributes/<br>
keys like<br>
description text or other things.<br>
<br>
> Thank you to each of you for all the work you do!<br>
<br>
</div></div>Hi,<br>
<br>
Sorry for a bit delayed answer but GDAL/OGR OSM driver developer had<br>
to do a couple of fixes for making this task to perform well.<br>
<br>
So you can do all that with GDAL OSM driver and SQL query language. Output<br>
can be despite CSV any other format that is supported by GDAL/OGR for<br>
writing.<br>
<a href="http://www.gdal.org/ogr/drv_osm.html" target="_blank">http://www.gdal.org/ogr/drv_osm.html</a><br>
<a href="http://www.gdal.org/ogr/ogr_formats.html" target="_blank">http://www.gdal.org/ogr/ogr_formats.html</a><br>
<br>
Install a very fresh GDAL development version, about rev. 24970 or higher.<br>
For Windows you can get it from gisinternals<br>
<a href="http://www.gisinternals.com/sdk/" target="_blank">http://www.gisinternals.com/sdk/</a><br>
<br>
You want to query streetname from osm lines and name and probably some other<br>
attributes from osm points and from a limited area. It is possible but quite<br>
slow to create such CSV file directly from OSM data file that can be in<br>
osm-xml or pbf format with following command<br>
<br>
ogr2ogr -f CSV streets.csv finland.osm.pbf -sql "select distinct<br>
name from lines where highway is not null order by name"<br>
-spat 24.821 60.123 25.259 60.317<br>
<br>
However, it is faster, especially if you want to do more queries,<br>
to convert OSM data first into Spatialite database. Here is a quite<br>
optimised command to use as a template<br>
<br>
ogr2ogr -f SQLite -dsco spatialite=yes finland.sqlite finland.osm.pbf<br>
 --config SQLITE_SYNCHRONOUS OFF --config OSM_COMPRESS_NODES YES<br>
 -progress<br>
<br>
This conversion takes a few minutes with 130 MB finland.osm.pbf file.<br>
Then you can repeat the first streetname search and it will be pretty fast<br>
<br>
ogr2ogr -f CSV streets.csv finland.sqlite -sql "select distinct name<br>
from lines where highway is not null order by name"<br>
-spat 24.821 60.123 25.259 60.317<br>
<br>
The poi file can be created in a similar way. Let's say you want to<br>
get all the amenities and names for those. The command is<br>
<br>
ogr2ogr -f CSV poi.csv finland.sqlite -sql "select name, amenity<br>
from points where amenity is not null order by amenity"<br>
-spat 24.821 60.123 25.259 60.317<br>
<br>
Note 1. Read the OSM driver manual page. The second command does not<br>
work before editing the defauld osmconf.ini file so that "amenity"<br>
is included in the points layer attributes.<br>
<br>
Note 2. There is a little bug in ogr2ogr CSV driver that may prevent<br>
creating a new csv file if there is already another CSV file with an<br>
uncommon structure in the same directory. The one-column CSV file that<br>
was created in the first example has such a structure. Delete the file<br>
or rename it with another extension before running the second example.<br>
<br>
Regards,<br>
<br>
-Jukka Rahkonen-<br>
<div><div><br>
<br>
<br>
<br>
_______________________________________________<br>
talk mailing list<br>
<a href="mailto:talk@openstreetmap.org" target="_blank">talk@openstreetmap.org</a><br>
<a href="http://lists.openstreetmap.org/listinfo/talk" target="_blank">http://lists.openstreetmap.org/listinfo/talk</a><br>
</div></div></blockquote></div><br></div>
</div>