0

i was following this http://workshops.boundlessgeo.com/tutorial-routing/#preparing-data tutorial about building a routing application and thus im stuck in the step of preparing the data as to i dont know where to execute the ogr commands that it says there. attached is the picture of the step and in it is the commands im talking about.screenshot of the tutorial

  • 1
    Looks like you're using windows, so you should have the OSGeo4W Shell that you use to run these commands – DPSSpatial Jul 11 '18 at 20:32
  • well i tried doing it earlier, but i wonder why it says no datasource provided. what i did was copy and paste the command on the shell. and shows errors like "no data source provided" and "not recognized etc.commands". thanks for the reply and sorry for such a stupid question. im just new in pgrouting and qgis. – AbdulMalik Mustapha Jul 11 '18 at 20:42
  • oh wait. after removing the backslashes and making it one line. it changed the error. saying "unable to open datasource "portland_maine.osm-line.php" witht the following drivers. – AbdulMalik Mustapha Jul 11 '18 at 20:44
  • 1
    GDAL/OGR is a beast to handle at the beginning, but at this point in your question, finding the issue here is a guessing game without the details of your setup... make absolutely sure you double checked the spelling (e.g. '.shp' instead of '.php' in your comment) and file name. can you open the data with e.g. QGIS and validate it's the data you expect? – geozelot Jul 12 '18 at 7:08
  • im using osgeo4w from qgis v2.18 in windows 10. postgresql 10.4 along with postgis with stackbuilder. that .php is a typo. sorry for that. i can open the shp file in qgis no problem at all. given admin priv to my osgeo4w but still cant solve the problem. i have another side question to raise sir? do i have to put the shp files in a specific folder(e.g where osgeo4w .exe is)? – AbdulMalik Mustapha Jul 12 '18 at 18:01
2

hi to all those who'd encounter this problem. here is how i was able to answer it. at first i used this command

ogr2ogr -where "highway <> ''" -select 'name,highway,oneway,surface' -lco GEOMETRY_NAME=the_geom -lco FID=id -t_srs EPSG:3857 -f PostgreSQL PG:"dbname=routing user=postgres" -nln edges portland-me.osm-line.shp

but it seems that i needed to arrange it the right way and specify the file path and an adivce is to give enough permission to the user that you are using. and even after overcoming the problem posted here. i got stopped by two other errors till i was successful. when you get to those two errors, you can read this one Import a shapefile to postgis with ogr2ogr gives: Unable to open datasource

thus the final command i used is this

ogr2ogr -select name,highway,oneway,surface -where "highway <> ''" -f "PostgreSQL" "PG:host=localhost user=postgres dbname=routing password=password" "E:\paopao theis files not to be deleted\portland-me.osm-line.shp" -lco GEOMETRY_NAME=the_geom -lco FID=gid -lco PRECISION=no -nlt PROMOTE_TO_MULTI -nln edges -overwrite

im so sorry if its not really well explained. even i myself dont completely understand how i made it. it was just through trial and error. cheers everyone

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.