GIS4DEV / GIS4DEV.github.io

Open Source GIScience & GIS for Development
1 stars 12 forks source link

Installing osm2pgsql on mac? #35

Closed emmaclinton closed 3 years ago

emmaclinton commented 3 years ago

Hi! Is anyone else working on a mac having trouble with opening and running osm2pgsql on their computer? I think I got everything working with the Homebrew installations, but the .bat file stuff isn't going as well. I went to Derrick's page looking for instructions but the link to the instructions page wasn't working.

vinfalardeau commented 3 years ago

Same, I got homebrew working but I haven't been able to execute osm2pgsql in my mac Terminal, even when following Derrick's instructions. If you open up Derrick's actual GitHub the instructions are in it, the link on his webpage is just not working because there's a typo in the url (scipts where it should read scripts). So this link should take you to his directions: https://derrickburt.github.io/opengis/sql/DSlab/scripts/osm2pgsqlMACOS.txt

When I've tried to run the command in Terminal, I get this error:

errorScreenshot

It looks like everything is working except maybe the database address? When using -d dsm, I get this error, but when I try changing it to my own database name, I get an error saying that the database doesn't exist.

vinfalardeau commented 3 years ago

If anyone else runs into "ERROR: Database error: ERROR: must be owner of table planet_osm_point," I finally figured out that you can fix it just by changing the default prefix from planet_osm to something else (I used osm) using the lowercase -p tag. You might also need to locate your sub-database using dollar signs in the database name. I named my database V_DarEsSalaam, so in my MacOS Terminal command I used -d dsm$V_DarEsSalaam$vincent.

The command that ended up working for me was:

/Users/vincentfalardeau/Desktop/open\ source/Lab3_SQL/1.4.1_1/bin/osm2pgsql -S /Users/vincentfalardeau/Desktop/open\ source/Lab3_SQL/1.4.1_1/share/osm2pgsql/default.style -d dsm$V_DarEsSalaam$vincent -U vincent -W -H artemis -P 5432 -p osm -x -l /Users/vincentfalardeau/Desktop/open\ source/Lab3_SQL/1.4.1_1/map.osm

Dunno if that helps anyone or if this is really related to your topic Emma, but yeah... osm2pgsql is tricky on a mac for sure

josephholler commented 3 years ago

Two thoughts:

  1. I hope everyone knows this is optional, since the OSM data is loaded into the public schema and you can query it from there. It's fun to learn how to do though.
  2. This might be a little more complicated because I've set you all up with an individual schema within one overarching dsm database, rather than setting you up with individual databases. Vincent's fix is addressing the issue of directing OSM2PGSQL to load the OSM data into your own schema, rather than somewhere else where you don't have user permissions to alter the database. Another way might be to use the --middle-schema and --output-schema options to specify your own schema. https://osm2pgsql.org/doc/man/latest.html