i was told that i could use osm2pgsql to dump osm data into a postgis db and from there i could export in a shapefil format. My question is how exactly do i do that? I have post gis and postgres and postgresql but i'm a bit lost as to what i need to do next in order to convert to shapefile format. Also, do i need to using Mapnik for this?
and i’m reading the python section about running the osm2gml.py script with the followng command cat yourfile.osm | ./osm2gml.py > yourfile.gml
however when i type that into my python command line i get an error >>> cat map_01_data.osm | ./osm2gml.py > map_01_data.gml
SyntaxError: invalid syntax. I have i done something wrong??? I have both the files under my c:\
i entered a similar command on windows dos prompt osm2gml.py < map_01_data.osm > map_01_data.gml but got errors
File "C:\osm2gml.py, line 86, in
xml.sax.parse <sys.stdin, osmParser >
IOError : [Errono 9] bad discriptor
although i did manage to conver my osm data into gml but it clearly it was not successful and it’s only 1kb. Do you know how i can rectify this becuase if i can convert this to gml, i can conver it to shapefile. I want to try using the osm2gml.py < map_01_data.osm > map_01_data.gml code first before doing anything else.
“xml.sax.parse <sys.stdin, osmParser >
IOError : [Errono 9] bad discriptor”
probably means that it didn’t understand the “<infile.osm >oufile.gml” syntax, where infile is “sys.stdin” in his case… You can try to write “cat infile.osm | osm2gml.py” instead not sure if it will work… Best would be if the script could support opening files on its own insed of using STDIN.
I’ve managed to convert my osm into gml then to shape file succesfully now using FWTools. I’ve got two other corresponding files, the .dbf and .shx. I used FWTools to view the shapefile and it showed a visual representation of the of the roads and how they joined. However, now what it is missing is the road names ON the shapefile. Is there anyway for me to use FWTools and my other 2 corresponding files to help make another layer, road_names.shp say,and add it on my map_data_01.shp file.
Well, from osm file, i converted it to gml format using the osm2gml.py file. From that, i used FWTools (http://fwtools.maptools.org/) which has ogr2ogr built into it using a command like ogr2ogr planet.shp planet.gml
to convert it to shape file. I mean, the orginal file ie. osm was all taken from the osm website, so i do not know why it would not show the names of the roads?? Any suggestions?
First step you’ve done was a conversion to gml. That’s xml as well, and you can check if street names are still there by opening the gml file with text editor. When it comes to shapefile format, it is actually a bunch of files with the same base name and different extensions. Attributes like street names are stored into .dbf file. It is dBase format and you can open it with spreadsheet programs like Excel or OpenOffice Calc.
FWTools is the Swiss knife of GIS. The package inludes OpenEV viewer and I suppose you have used it for viewing your shapefile. It can show the attributes as well but I suggest you to let it be and use some more feature rich software. OpenEV if fine viewer for raster data and it can handle for example native Landsat scenes with all 8 bands but its vector handling capabilities are limited.
You may try OpenJUMP or Quantum GIS (version 0.11 does not work with my Vista but the older 0.10 does). Some people like uDig. All those can be used not only for viewing but also for editing data. If you want just to look at the data then Tatuk GIS viewer is pretty good for that.
what i ultimately want to do is to convert my osm file, into a shapefile which not only shows the roads, but shows the names corresponding to them. Because at present it just shows the roads a no names which i found very strange. I assumed that after converting it from gml to shapefile, i would see both roads and the names. With my db file, is there anyway for me to add those names onto my shapefile because ideally with any road map, there needs to have roads names, not just a bunch of lines connected together.
In a nut shell, my objective is to convert my osm into shapefil so i see BOTH the roads and the NAMES!!
Clearly it did not work when u used FWTools because again, it did have 0gr20gr built into it but from what i tell i’m getting close.
What should i do inorder for me to have my road names appear on my shapefile?
That’s because it’s not showing roads, just lines, but the lines have attributes that make them roads, e.g. names and road type. Since OSM have all kinds of types of lines roads/lakes/buildings, you need to style your render in some way using a stylesheet… (I’m just guessing here)
Well, shapefile is just a binary file containing data. Vector coordinates are stored into .shp file and attribute data into .dbf file. It is not much to look at if you don’t use some sort of GIS viewer.
Your principal problem with OpenEV viewer, for example, is that by default it does not show the names or “labels”, which they are often called. If you open the layer control, right click on your converted OSM data layer you will see on the second tab “Draw Styles” that the last box “Labels” is by default set to “disabled”. In theory you can see the labels in OpenEV user if you select the field to be used for labeling from the pull-down menu. In theory because I think that OpenEV has some kind of the bug in this. Naturally I now assume that you have the names transferred correctly into shapefile, but that you have for sure already checked from the .dbf file.
I recommend next to download one GIS viewer, they all behave in a similar way. Find out a place to tell the software that you want to see your ways labeled and point out the field to be used for labeling. The software do not know without you telling it if you want to see road names of reference numbers or what as labels.
Quantum GIS and OpenJUMP do both offer fine features for styling roads and labels, like selecting the colours and widths, label fonts, font size, the scale when labels come visible etc. Try all the controls and see what happens.
Thanks for your reply. I tried to add the labels but it unfortunately did not show up :(. I even made the font blue and size 20pt but it did not have any affect at all. I take it this is where the bug comes in, thanks OpenEV!! If i download something like OpenJump, will it allow me to add the names ontop of my shapefile? yes or no?
btw, i did check my dbf and yes it does contain the names.
I think that how to is needed, there are so many utils and other stuff that needs explaining for OSM folks.
I don’t use Windows at all so I can’t write it, I could spend sometime to do it for MacOSX but I hae no idea what utils work on Mac. AxelM on the Swedish subforum uses Illustrator+commerical plugins to make maps on the mac, what he describe seems like a very manual process though.
I downloaded the openjump app, and found it quite appealing than the fwtools is. I'm reading this link here [http://openjump.org/wiki/show/Index](http://openjump.org/wiki/show/Index) to show me how to use it, but i can't seem to find a way for me to display the road names on my shapefile. Although i can view the attributes like name being the road names ect, but can't seem to figure out how to display the road names. I thought about adding a new layer called road names, but at that point this would mean i would have to some how convert my db file into shapefile, then load that into the application which seems overcomplicating the matter. Any suggestions how i could see the names?