Hello, On May 19, 2013 5:55 AM, "Andrew Salzberg" <[email protected]> wrote: > > Hi, > > i have a small .osm file extracted from the overpass api, and I was hoping to load it into a postGIS database using osm2pgsql. > > I have the .osm file, and i have osm2pgsql on my mac, and i have postgres running on my machine (and pgadmin to poke around). But - I can't seem to find a good newbie description of loading an .osm file (not necessarily planet.osm) into a postgis database - maybe someone on the list can point me in the right direction? Or maybe give me some quick pointers? >
This is from an old blog post that I wrote: Next, we need to setup a database to load the OSM data. This could be done in the following steps. $ sudo -u postgres createuser <username> $ sudo -u postgres createdb -E UTF8 -O <username> <dbname> $ sudo -u postgres createlang plpgsql <dbname> Now add the postgis extensions. Note the location of the lwpostgis.sql file may vary. $ sudo -u postgres psql -d <dbname> -f /usr/share/postgresql-8.3-postgis/lwpostgis.sql (later versions of postgresql, the lwpostgis.sql file has been renamed to postgis.sql) Next give access to the user to update the postgis metatables. $ sudo -u postgres psql -d <dbname> -c “ALTER TABLE geometry_columns OWNER TO <username>” $ sudo -u postgres psql -d <dbname> -c “ALTER TABLE spatial_ref_sys OWNER TO <username>” Apply 900913 diff which is not normally included with postgis, you can get it from the source of osm2pgsql. To add it you should run: $ sudo -u postgres psql -d <dbname> -f 900913.sql Run, osm2pgsql, this should load the OSM data into the database we just created. $ osm2pgsql <osm_file> -d <database_name> -U <user_name> The complete post is here http://sajjad.in/2010/04/bridging-the-gap/ It uses PostgreSQL 8.3. I hope you are using 9.1. Also, see the OSM wiki for more details: http://wiki.openstreetmap.org/wiki/Osmosis/PostGIS_Setup Cheers, Sajjad. > thanks in advance! > > Andrew > > _______________________________________________ > newbies mailing list > [email protected] > http://lists.openstreetmap.org/listinfo/newbies >
_______________________________________________ newbies mailing list [email protected] http://lists.openstreetmap.org/listinfo/newbies

