Skip to content

Commit 1711edc

Browse files
committed
Update the README a bit
1 parent f41bcfd commit 1711edc

1 file changed

Lines changed: 48 additions & 28 deletions

File tree

README

Lines changed: 48 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
osm2pgsql
22
=========
3-
Converts OSM planet.osm data to a PostgreSQL database suitable
4-
for rendering into map tiles by Mapnik.
3+
Converts OSM planet.osm data to a PostgreSQL / PostGIS database suitable
4+
for specific applications like rendering into map tiles by Mapnik
5+
or geocoding with Nominatim.
6+
7+
osm2pgsql currently supports two different database schemas
8+
1) A database schema that is optimized for ease of rendering
9+
by Mapnik.
10+
2) A database schema that is optimized for geocoding with Nominatim,
11+
emphasizing the spatially hierarchical organizations of objects.
12+
13+
Both schemas were specifically optimized for the purpose they were
14+
intended for and they may therefore be less suitable for other
15+
general purpose processing. Nevertheless, the rendering schema
16+
might be useful for other purposes as well, and has been used
17+
for a variety of additionally purposes.
518

6-
The format of the database is optimised for ease of rendering
7-
by mapnik. It may be less suitable for other general purpose
8-
processing.
919

1020
For a broader view of the whole map rendering tool chain see
1121
http://wiki.openstreetmap.org/index.php/Mapnik
@@ -20,23 +30,23 @@ http://wiki.openstreetmap.org/index.php/Mailing_lists
2030

2131
Features
2232
========
23-
- Converts OSM files to a postgresql DB
33+
- Converts OSM files to a PostgreSQL DB
2434
- Conversion of tags to columns is configurable in the style file
25-
- Able to read .gz, .bz2 and .pbf files directly
35+
- Able to read .gz, .bz2, .pbf and .o5m files directly
2636
- Can apply diffs to keep the database up to data
2737
- Support the choice of output projection
2838
- Configurable table names
29-
- Gazetteer backend for Nominatim
39+
- Gazetteer back-end for Nominatim
3040
http://wiki.openstreetmap.org/wiki/Nominatim
3141
- Support for hstore field type to store the complete set of tags in one database
3242
field if desired
3343

3444
Source code
3545
===========
36-
The latest source code is available in the OSM SVN repository
46+
The latest source code is available in the OSM git repository on github
3747
and can be downloaded as follows:
3848

39-
$ svn co http://svn.openstreetmap.org/applications/utils/export/osm2pgsql
49+
$ git clone git://github.com/openstreetmap/osm2pgsql.git
4050

4151
Build requirements
4252
==================
@@ -66,15 +76,15 @@ e.g. on Fedora:
6676
# yum install geos-devel proj-devel postgresql-devel libxml2-devel bzip2-devel gcc-c++
6777

6878
on Debian:
69-
# aptitude install libxml2-dev libgeos-dev libpq-dev libbz2-dev proj autoconf automake libtool make g++
79+
# aptitude install libxml2-dev libgeos-dev libgeos++-dev libpq-dev libbz2-dev libproj-dev protobuf-c-compiler libprotobuf-c0-dev autoconf automake libtool make g++
7080

7181
On most Unix-like systems the program can be compiled by
7282
running './autogen.sh && ./configure && make'.
7383

7484
Operation
7585
=========
7686
You must create a PostgreSQL user and a database with the
77-
postgis functions enabled. This requires access as the
87+
PostGIS functions enabled. This requires access as the
7888
database administrator, normally the 'postgres' user.
7989

8090
The default name for this database is 'gis' but this may
@@ -95,19 +105,19 @@ $ sudo -u postgres createuser <username>
95105
$ sudo -u postgres createdb -E UTF8 -O <username> <dbname>
96106
$ sudo -u postgres createlang plpgsql <dbname>
97107

98-
Adding the postgis extensions. Note the location of the
108+
Adding the PostGIS extensions. Note the location of the
99109
files may vary.
100110

101111
$ sudo -u postgres psql <dbname> < /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
102112
$ sudo -u postgres psql <dbname> < /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
103113

104114
Next we need to give the <username> access to update the postgis
105-
metadata tables
115+
meta-data tables
106116

107117
$ sudo -u postgres psql -d <dbname> -c "ALTER TABLE geometry_columns OWNER TO <username>"
108118
$ sudo -u postgres psql -d <dbname> -c "ALTER TABLE spatial_ref_sys OWNER TO <username>"
109119

110-
The 900913 is not normally included with postgis. To add it you
120+
The 900913 is not normally included with PostGIS. To add it you
111121
should run:
112122

113123
$ sudo psql -u postgres psql -d <dbname> -f 900913.sql
@@ -117,17 +127,27 @@ hstore-new extension.
117127

118128
$ sudo -u postgres psql <dbname> < /usr/share/postgresql/8.4/contrib/hstore.sql
119129

130+
On PostgreSQL 9.1 and above, you can install it by running "CREATE EXTENSION hstore;"
131+
in your database.
132+
120133
Now you can run osm2pgsql to import the OSM data.
121134
This will perform the following actions:
122135

123-
1) Osm2pgsql connects to database and creates the following 4 tables:
136+
1) Osm2pgsql connects to database and creates the following 4 tables
137+
when used with the default output back-end (pgsql):
124138
- planet_osm_point
125139
- planet_osm_line
126140
- planet_osm_roads
127141
- planet_osm_polygon
128142
The prefix "planet_osm" can be changed with the --prefix option,
129143
the above is the default.
130144

145+
If you are using --slim mode, it will create the following additional 3 tables:
146+
- planet_osm_nodes
147+
- planet_osm_ways
148+
- planet_osm_rels
149+
150+
131151
2) Runs an XML parser on the input file (typically planet.osm)
132152
and processes the nodes, ways and relations.
133153

@@ -136,26 +156,26 @@ the above is the default.
136156
the position is noted, but not added to the database.
137157

138158
4) Ways are read in converted into WKT geometries by using the
139-
postitions of the nodes read in earlier. If the tags on the way
159+
positions of the nodes read in earlier. If the tags on the way
140160
are listed in the style file then the way will be written into
141161
the line or roads tables.
142162

143-
5) If the way has one or more tags marked as 'poloygon' and
144-
forms a closed ring then it will be added to the lanet_osm_polygon
163+
5) If the way has one or more tags marked as 'polygon' and
164+
forms a closed ring then it will be added to the planet_osm_polygon
145165
table.
146166

147167
6) The relations are parsed. Osm2pgsql has special handling for a
148168
limited number of types: multipolygon, route, boundary
149169
The code will build the appropriate geometries by referencing the
150-
members and outputing these into the database.
170+
members and outputting these into the database.
151171

152172
7) Indexes are added to speed up the queries by Mapnik.
153173

154-
Tuning postgresql
174+
Tuning PostgreSQL
155175
=================
156176

157-
For an efficient operation of postgresql you will need to tune the config
158-
parameters of postgresql from its default values. These are set in the
177+
For an efficient operation of PostgreSQL you will need to tune the config
178+
parameters of PostgreSQL from its default values. These are set in the
159179
config file at /etc/postgresql/8.4/main/postgresql.conf
160180

161181
The values you need to set will depend on the hardware you have available,
@@ -175,19 +195,19 @@ Depending on the command-line switches you can select which projection you
175195
want the database in. You have three choices:
176196

177197
4326: The standard lat/long coordinates
178-
900913: The spherical mercator projection, used by TileCache, Google Earth etc.
179-
3395: The legacy (broken) WGS84 mercator projection
198+
900913: The spherical Mercator projection, used by TileCache, Google Earth etc.
199+
3395: The legacy (broken) WGS84 Mercator projection
180200

181201
Depending on what you're using one or the other is appropriate. The default
182-
mapnik style (osm.xml) assumes that the data is stored in 900913 and this
202+
Mapnik style (osm.xml) assumes that the data is stored in 900913 and this
183203
is the default for osm2pgsql.
184204

185205
Combining the -v and -h switches will tell about the exact definitions of
186206
the projections.
187207

188208
In case you want to use some completely different projection there is the -E
189-
option. It will initialise the projection as +init=epsg:<num>. This allows
190-
you to use any projection recognised by proj4, which is useful if you want
209+
option. It will initialize the projection as +init=epsg:<num>. This allows
210+
you to use any projection recognized by proj4, which is useful if you want
191211
to make a map in a different projection. These projections are usually
192212
defined in /usr/share/proj/epsg.
193213

0 commit comments

Comments
 (0)