osm2pgrouting (#24) - osm2pgrouting on win32 (#214) - Message List

osm2pgrouting on win32

Hi, I've read that osm2pgrouting tool is only tested on Linux distributions: there's not a win installer. But, for my project, I have to import osm data to postgreSQL db and I'm using a win32 system. I've found another tool directly from OSM project, "osm2pgsql", but I don't know if using that tool I could have problems using pgRouting functions. I've also found that I could get shapefiles (or other formats) from CloudMade?.

So my question is: if I import data from shape or with osm2pgsql I coud have problems using pgRouting functions on that data? And if the answer is "yes", what is the solution? Please, help!

  • Message #765

    You could import your data with osm2pgRouting on a linux (virtual) machine, then make a database dump and import it on your windows PC. There is a VMWare image of the FOSS4G2009 pgRouting workshop where everything is installed: http://pgrouting.postlbs.org/wiki/WorkshopFOSS4G2008 .
    In case you have a lot of data to convert it might take longer with a virtual machine and you might have a to mount an external drive.

    Taking the shape files from CloudMade? is an interesting option, but I didn't try yet. It's not difficult to import a shape file to PostgreSQL. You might want to start with one of the workshop tutorials, which might answer most or all of your questions then.

    • Message #769

      I've tried to import OSM data with shape, osm2pgsql and osm2pgrouting, but only the last one have a proper format of tables (see table ways) for pgRouting functions.

      I used osm2pgrouting on a VMWare image (FOSS4G2008_japan version) but only using capetown.osm it creates and populates all tables. With a bigger .osm file ( Italy is about 600MB from CloudMade?) after 2-3 hours the process automatically kill itself ('Killed' in command prompt): no data in 'ways' table and no 'vertices_tmp' table. I don't know if the problem depends on virtual memory of the VM or other.

      • Message #770

        This problem happened to me, too, when I tried to import a larger area of OSM. The current converter keeps temporary results in memory to process them later. When you run out of memory the process fails, so it depends on the memory you have available.

        This is not really a good design, I know, and it would make sense to write temporary results to database from time to time (which would decrease performance then). But there was no time (and/or support) yet to solve this issue.

        • Message #771

          Ok, finally tonight (or very very early in the morning...) I've created a .sql file that use shapefile from CloudMade? and it'is very fast: it creates tables 'types' and 'classes', add pgrouting functionality (other fields in table 'ways' for routing), and creates field 'class_id::integer' in 'ways' referenced to identifier in 'classes'. Note I've modified 4 records in 'classes' because the 'id' has to be a unique identifier! (id 100, 106, 107).

          The only problem now is that many records have field 'class_id' empty because in shapefile there's only the field 'type:text' that is the name (motorway, primary, track..) but in table 'classes' I have 2 records with name 'track'!! I should have another field in the shape to identify unequivocally the class and type of way to calculate 'class_id'. (Aarghh: mental insanity welcomed..)

          I think, now, I'll cancel that record to solve all of my problems.. (that's the right spirit! :-P)

          • Message #773

            Nice to see that you had some progress ;-)
            This time I had some problems to follow your explanation about classes, types and ID's. Did you make your changes in http://pgrouting.postlbs.org/browser/tools/osm2pgrouting/trunk/mapconfig.xml ?

            Because I work in Japan and the OSM data here is still not so good, I just used this converter for data of Cape Town. I'm not sure this XML works well for other countries, but it should follow the attributes described in the OSM wiki.

            If you find any logical errors or have some ideas for improvement, I'm glad to hear about. If you could make it work you're also welcome to "hack" the pgRouting wiki and describe how you did.

            Any comments and criticism welcome!

            • Message #788

              I am sorry to have replied late.

              I haven't used any mapconfig.xml because I've imported OSM data from shapefile: I've created tables 'types' and 'classes' following the attributes described in the OSM wiki BUT in some fields I had to change the name attribute (see '_FIXED' below..) to assign a 'class_id' for each record starting from shape data. In shapefile there's only a field with the name (motorway, primary, track..) and not also with the type (highway, cycleway,tracktype, junction).

              For example, to import from .shp (not from .osm) I should have: ..<type name="cycleway" id="2"> <class name="track_FIXED" id="202" />..

              This problem become from shape data not from osm2pgrouting tool (because I don't use it): it'll be solved when in shapefiles we have a field for 'class_name' and a field for 'type_name'. When you have time take a look at shapefiles from CloudMade?: (1) they don't have a field to identify a 'type_id' (2) they don't have a field to identify a unique 'osm_id' but only a serial.

              For the rest I'll be very glad to contribute and describe how to import from shape, but not now 'cause in these weeks I absolutely have to complete my thesis project!

              • Message #792

                Hi,

                I didn't have the time to look at CloudMade? shape files, but I guess that the osm2pgrouting converter won't work then anymore as it is.

                If you have some C programming skills you could look into the code and maybe make some changes there to make it work for you. Otherwise you might better try the standard way to create tables and topology "by hand" like explained in the workshops for example.

                The problem with the standard OSM files is that the network is not defined as someone might expect. This might have changed in the Shape files of CloudMade? as they also do routing with OSM data.
                In the original data model ways can consist of several links, and osm2pgrouting does some conversion there.

                Stuff like types are not required for routing, so it's nice to have them, but what you need is a network topology with links, that have a source and a target ID. For Dijkstra you even didn't need a geometry information.