{"id":18739571,"url":"https://github.com/springmeyer/osm2pgsql-svn","last_synced_at":"2025-11-19T13:30:17.543Z","repository":{"id":5581995,"uuid":"6788067","full_name":"springmeyer/osm2pgsql-svn","owner":"springmeyer","description":"SVN mirror + windows build files","archived":false,"fork":false,"pushed_at":"2012-11-21T01:24:48.000Z","size":356,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-12-28T18:28:14.426Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/springmeyer.png","metadata":{"files":{"readme":"README","changelog":"ChangeLog","contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-21T01:13:22.000Z","updated_at":"2019-08-13T15:12:04.000Z","dependencies_parsed_at":"2022-08-26T19:43:35.006Z","dependency_job_id":null,"html_url":"https://github.com/springmeyer/osm2pgsql-svn","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/springmeyer%2Fosm2pgsql-svn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/springmeyer%2Fosm2pgsql-svn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/springmeyer%2Fosm2pgsql-svn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/springmeyer%2Fosm2pgsql-svn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/springmeyer","download_url":"https://codeload.github.com/springmeyer/osm2pgsql-svn/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239619570,"owners_count":19669447,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T15:36:23.434Z","updated_at":"2025-11-19T13:30:17.492Z","avatar_url":"https://github.com/springmeyer.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"osm2pgsql\n=========\nConverts OSM planet.osm data to a PostgreSQL database suitable \nfor rendering into map tiles by Mapnik.\n\nThe format of the database is optimised for ease of rendering\nby mapnik. It may be less suitable for other general purpose\nprocessing.\n\nFor a broader view of the whole map rendering tool chain see\nhttp://wiki.openstreetmap.org/index.php/Mapnik \nhttp://wiki.openstreetmap.org/index.php/Osm2pgsql\nhttp://wiki.openstreetmap.org/index.php/Slippy_Map\n\nYou may find that the wiki pages are more up to date than this\nreadme and may include answers to issues not mentioned here.\n\nAny questions should be directed at the osm dev list\nhttp://wiki.openstreetmap.org/index.php/Mailing_lists \n\nFeatures\n========\n- Converts OSM files to a postgresql DB\n- Conversion of tags to columns is configurable in the style file\n- Able to read .gz, .bz2 and .pbf files directly\n- Can apply diffs to keep the database up to data\n- Support the choice of output projection\n- Configurable table names\n- Gazetteer backend for Nominatim\n  http://wiki.openstreetmap.org/wiki/Nominatim\n- Support for hstore field type to store the complete set of tags in one database\n  field if desired\n\nSource code\n===========\nThe latest source code is available in the OSM SVN repository \nand can be downloaded as follows:\n\n$ svn co http://svn.openstreetmap.org/applications/utils/export/osm2pgsql\n\nBuild requirements\n==================\nThe code is written in C and C++ and relies on the libraries\nbelow:\n- libxml2    http://xmlsoft.org/\n- geos       http://geos.refractions.net/\n- proj       http://www.remotesensing.org/proj/\n- bzip2      http://www.bzip.org/\n- zlib       http://www.zlib.net/\n- PostgreSQL http://www.postgresql.org/\n- PostGIS    http://postgis.refractions.net/\n\nTo make use of the database generated by this tool you will\nprobably also want to install:\n- Mapnik from http://mapnik.org/\n\n\n\nBuilding\n========\nMake sure you have installed the development packages for the \nlibraries mentioned in the requirements section and a C and C++\ncompiler.\n\ne.g. on Fedora:\n# yum install geos-devel proj-devel postgresql-devel libxml2-devel bzip2-devel gcc-c++\n\non Debian:\n# aptitude install libxml2-dev libgeos-dev libpq-dev libbz2-dev proj autoconf automake libtool make g++\n\nOn most Unix-like systems the program can be compiled by\nrunning './autogen.sh \u0026\u0026 ./configure \u0026\u0026 make'.\n\nOperation\n=========\nYou must create a PostgreSQL user and a database with the \npostgis functions enabled. This requires access as the\ndatabase administrator, normally the 'postgres' user.\n\nThe default name for this database is 'gis' but this may\nbe changed by using the osm2pgsql --database option.\n\nIf the \u003cusername\u003e matches the unix user id running the import\nand rendering then this allows the PostgreSQL 'ident sameuser'\nauthentication to be used which avoids the need to enter a\npassword when accessing the database. This is setup by default\non many Unix installs but does not work on Windows (due to the\nlack of unix sockets).\n\nSome example commands are given below but you may find\nthis wiki page has more up to data information:\nhttp://wiki.openstreetmap.org/wiki/Mapnik/PostGIS\n\n$ sudo -u postgres createuser \u003cusername\u003e\n$ sudo -u postgres createdb -E UTF8 -O \u003cusername\u003e \u003cdbname\u003e\n$ sudo -u postgres createlang plpgsql \u003cdbname\u003e\n\nAdding the postgis extensions. Note the location of the\nfiles may vary.\n\n$ sudo -u postgres psql \u003cdbname\u003e \u003c /usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql\n$ sudo -u postgres psql \u003cdbname\u003e \u003c /usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql\n\nNext we need to give the \u003cusername\u003e access to update the postgis\nmetadata tables\n\n$ sudo -u postgres psql -d \u003cdbname\u003e -c \"ALTER TABLE geometry_columns OWNER TO \u003cusername\u003e\"\n$ sudo -u postgres psql -d \u003cdbname\u003e -c \"ALTER TABLE spatial_ref_sys  OWNER TO \u003cusername\u003e\"\n\nThe 900913 is not normally included with postgis. To add it you\nshould run:\n\n$ sudo psql -u postgres psql -d \u003cdbname\u003e -f 900913.sql\n\nIf you want to use hstore support then you will also need to enable the PostgreSQL\nhstore-new extension.\n\n$ sudo -u postgres psql \u003cdbname\u003e \u003c /usr/share/postgresql/8.4/contrib/hstore.sql\n\nNow you can run osm2pgsql to import the OSM data.\nThis will perform the following actions:\n\n1) Osm2pgsql connects to database and creates the following 4 tables:\n   - planet_osm_point\n   - planet_osm_line\n   - planet_osm_roads\n   - planet_osm_polygon\nThe prefix \"planet_osm\" can be changed with the --prefix option, \nthe above is the default.\n\n2) Runs an XML parser on the input file (typically planet.osm) \n and processes the nodes, ways and relations.\n\n3) If a node has a tag declared in the style file then it is \n added to planet_osm_point. If it has no such tag then\n the position is noted, but not added to the database.\n\n4) Ways are read in converted into WKT geometries by using the \n postitions of the nodes read in earlier. If the tags on the way \n are listed in the style file then the way will be written into\n the line or roads tables.\n\n5) If the way has one or more tags marked as 'poloygon' and \n forms a closed ring then it will be added to the lanet_osm_polygon\n table.\n\n6) The relations are parsed. Osm2pgsql has special handling for a\n limited number of types: multipolygon, route, boundary\n The code will build the appropriate geometries by referencing the\n members and outputing these into the database.\n\n7) Indexes are added to speed up the queries by Mapnik.\n\nTuning postgresql\n=================\n\nFor an efficient operation of postgresql you will need to tune the config\nparameters of postgresql from its default values. These are set in the\nconfig file at /etc/postgresql/8.4/main/postgresql.conf\n\nThe values you need to set will depend on the hardware you have available,\nbut you will likely need to increase the values for the following parameters:\n\n- shared_buffers\n- checkpoint_segments\n- work_mem\n- maintenance_work_mem\n- effective_cache_size\n\n\nA quick note on projections\n===========================\n\nDepending on the command-line switches you can select which projection you\nwant the database in. You have three choices:\n\n4326: The standard lat/long coordinates\n900913: The spherical mercator projection, used by TileCache, Google Earth etc.\n3395: The legacy (broken) WGS84 mercator projection\n\nDepending on what you're using one or the other is appropriate. The default\nmapnik style (osm.xml) assumes that the data is stored in 900913 and this \nis the default for osm2pgsql.\n\nCombining the -v and -h switches will tell about the exact definitions of\nthe projections.\n\nIn case you want to use some completely different projection there is the -E\noption. It will initialise the projection as +init=epsg:\u003cnum\u003e. This allows\nyou to use any projection recognised by proj4, which is useful if you want\nto make a map in a different projection. These projections are usually\ndefined in /usr/share/proj/epsg.\n\nDatabase Access Examples\n========================\nIf you wish to access the data from the database then the\nqueries below should give you some hints. Note that these \nexamples all use the 'latlong' projection which is not the\ndefault.\n\n$ psql gis\ngis=\u003e \\d\n               List of relations\n Schema |        Name        | Type  |  Owner\n--------+--------------------+-------+----------\n...\n public | planet_osm_line    | table | jburgess\n public | planet_osm_point   | table | jburgess\n public | planet_osm_polygon | table | jburgess\n public | planet_osm_roads   | table | jburgess\n...\n\ngis=\u003e \\d planet_osm_line\n  Table \"public.planet_osm_line\"\n  Column   |   Type   | Modifiers\n-----------+----------+-----------\n osm_id    | integer  |\n name      | text     |\n place     | text     |\n landuse   | text     |\n... [ lots of stuff deleted ] ...\n way       | geometry | not null\n z_order   | integer  | default 0\n\n\nEach of the tables contains a subset of the planet.osm file representing\na particular geometry type\n- Point contains nodes which have interesting tags\n  e.g. place=city, name=London\n  \n- Line contains ways with interesting tags\n  e.g. highway=motorway, ref=M25\n  \n- Polygon contains ways which form an enclosed area\n  e.g. landuse=reservoir\n\nThe DB columns are used as follows:\n- osm_id = the planet.osm ID of the node(point) or way(line,polygon)\n- name, place, landuse, ... = the value of the given key, if present on\nthe node/way. If the tag is not present, the value is NULL. Only a\nsubset of all possible tags are stored in the DB. Only ones rendered in\nthe osm.xml are actually interesting to mapnik.\n- way = PostGIS geometry describing the physical layout of the object.\n\n\nQuerying specific data requires knowlege of SQL and the OSM key/value\nsystem, e.g.\n\ngis=\u003e select osm_id,astext(way),name from planet_osm_point where amenity='cinema' limit 5;\n  osm_id  |                  astext                   |        name\n----------+-------------------------------------------+--------------------\n 26236284 | POINT(-79.7160836579093 43.6802306464618) |\n 26206699 | POINT(51.4051989797638 35.7066045032235)  | Cinema Felestin\n 26206700 | POINT(51.3994885141459 35.7058460359352)  | Cinema Asr-e Jadid\n 20979630 | POINT(151.225781789807 -33.8943079539886) | Paris Cinema\n 20979684 | POINT(151.226855394904 -33.8946830511095) | Hoyts\n(5 rows)\n\nMapnik renders the data in each table by applying the rules in the\nosm.xml file.\n\n\n\u003e How could I get e.g. all highways in a given bounding box?\n\nThe 'way' column contains the geo info and is the one which you need to\nuse in your WHERE clause. e.g.\n\ngis=\u003e select osm_id,highway,name from planet_osm_line where highway is not null and way \u0026\u0026 GeomFromText('POLYGON((0 52, 0.1 52, 0.1 52.1, 0 52.1, 0 52))',4326);\n \nosm_id  |   highway    |       name\n---------+--------------+------------------\n 4273848 | unclassified |\n 3977133 | trunk        | to Royston (tbc)\n 4004841 | trunk        |\n 4019198 | trunk        |\n 4019199 | trunk        |\n 4238966 | unclassified |\n\n\nSee the Postgis docs for details, e.g.\nhttp://postgis.refractions.net/docs/ch04.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspringmeyer%2Fosm2pgsql-svn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspringmeyer%2Fosm2pgsql-svn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspringmeyer%2Fosm2pgsql-svn/lists"}