├── .gitignore ├── 404.html ├── Gemfile ├── README.md ├── _bin └── check_ids_in_manual.sh ├── _config.yml ├── _data └── dependencies.yml ├── _includes ├── download.html ├── examples.md ├── heading-links.html ├── highlight.css ├── img │ ├── archive.svg │ ├── book.svg │ ├── community.svg │ ├── download.svg │ ├── faq.svg │ ├── features.svg │ ├── from-source.svg │ ├── history.svg │ ├── logo-apple.svg │ ├── logo-docker.svg │ ├── logo-freebsd.svg │ ├── logo-github.svg │ ├── logo-tux.svg │ ├── logo-windows.svg │ ├── manpages.svg │ ├── tutorials.svg │ └── users.svg └── sponsors.md ├── _layouts ├── default.html ├── doc.html ├── examples.html ├── manpage.html ├── post.html └── release.html ├── _manpages ├── osm2pgsql-1.10.0.md ├── osm2pgsql-1.11.0.md ├── osm2pgsql-1.3.0.md ├── osm2pgsql-1.4.0.md ├── osm2pgsql-1.4.1.md ├── osm2pgsql-1.4.2.md ├── osm2pgsql-1.5.0.md ├── osm2pgsql-1.5.1.md ├── osm2pgsql-1.5.2.md ├── osm2pgsql-1.6.0.md ├── osm2pgsql-1.7.0.md ├── osm2pgsql-1.7.1.md ├── osm2pgsql-1.7.2.md ├── osm2pgsql-1.8.0.md ├── osm2pgsql-1.8.1.md ├── osm2pgsql-1.9.0.md ├── osm2pgsql-1.9.1.md ├── osm2pgsql-1.9.2.md ├── osm2pgsql-2.0.0.md ├── osm2pgsql-2.0.1.md ├── osm2pgsql-2.1.0.md ├── osm2pgsql-2.1.1.md ├── osm2pgsql-gen-2.0.0.md ├── osm2pgsql-gen-2.0.1.md ├── osm2pgsql-gen-2.1.0.md └── osm2pgsql-gen-2.1.1.md ├── _manual-v1 ├── 01-intro.md ├── 02-requirements.md ├── 03-database.md ├── 04-geometries.md ├── 05-running.md ├── 06-flex-output.md ├── 07-pgsql-output.md ├── 08-middle.md ├── 09-expire.md ├── 10-generalization.md ├── 11-advanced-topics.md ├── 12-tips-and-tricks.md ├── A-preparing-input-data.md ├── B-lua-lib.md ├── C-options.md ├── D-upgrading.md ├── E-sizing.md └── options │ ├── advanced.md │ ├── database.md │ ├── expire.md │ ├── help-version.md │ ├── input.md │ ├── logging.md │ ├── main.md │ ├── middle.md │ ├── output.md │ └── pgsql.md ├── _manual-v2 ├── 01-intro.md ├── 02-requirements.md ├── 03-database.md ├── 04-geometries.md ├── 05-running.md ├── 06-flex-output.md ├── 07-pgsql-output.md ├── 08-middle.md ├── 09-expire.md ├── 10-generalization.md ├── 11-advanced-topics.md ├── 12-tips-and-tricks.md ├── A-preparing-input-data.md ├── B-lua-lib.md ├── C-options.md ├── D-upgrading.md ├── E-sizing.md └── options │ ├── advanced.md │ ├── database.md │ ├── expire.md │ ├── help-version.md │ ├── input.md │ ├── logging.md │ ├── main.md │ ├── middle.md │ ├── output.md │ └── pgsql.md ├── _posts ├── 2020-07-28-release-1.3.0.md ├── 2020-09-23-new-website.md ├── 2020-10-21-problems-with-postgresql-jit.md ├── 2020-12-07-release-1.4.0.md ├── 2021-01-12-1000-stars.md ├── 2021-01-14-virtual-meetup.md ├── 2021-02-03-release-1.4.1.md ├── 2021-02-07-successful-community-meetup.md ├── 2021-04-07-release-1.4.2.md ├── 2021-05-16-upcoming-talks.md ├── 2021-06-02-release-1.5.0.md ├── 2021-07-29-release-1.5.1.md ├── 2021-09-30-past-and-upcoming-conference-talks.md ├── 2022-01-11-release-1.5.2.md ├── 2022-01-24-release-1.6.0.md ├── 2022-08-15-release-1.7.0.md ├── 2022-08-30-new-test-server.md ├── 2022-09-06-generalization-project-started.md ├── 2022-09-13-security-audit.md ├── 2022-09-22-developer-interview.md ├── 2022-10-04-book-release.md ├── 2022-10-05-release-1.7.1.md ├── 2022-10-23-timings-and-sizes.md ├── 2022-11-10-release-1.7.2.md ├── 2023-01-22-faster-with-postgresql15.md ├── 2023-01-28-release-1.8.0.md ├── 2023-02-13-release-1.8.1.md ├── 2023-07-25-middle-improvements.md ├── 2023-08-16-release-1.9.0.md ├── 2023-08-18-where-we-are-going.md ├── 2023-08-22-release-1.9.1.md ├── 2023-09-04-release-1.9.2.md ├── 2023-09-11-announcing-themepark.md ├── 2023-09-20-new-github-organisation.md ├── 2023-09-25-2nd-virtual-meetup.md ├── 2023-11-07-release-1.10.0.md ├── 2023-12-10-sotm-eu-talk.md ├── 2024-02-12-release-1.11.0.md ├── 2024-04-01-osm2pgsql-goes-ai.md ├── 2024-09-19-release-2.0.0.md ├── 2024-11-21-crunchydata-is-loading-the-world.md ├── 2024-12-02-release-2.0.1.md ├── 2025-02-06-sovereign-tech-fellowship.md ├── 2025-04-07-release-2.1.0.md └── 2025-04-14-release-2.1.1.md ├── _releases ├── 1.0.0.md ├── 1.10.0.md ├── 1.11.0.md ├── 1.2.0.md ├── 1.2.1.md ├── 1.2.2.md ├── 1.3.0.md ├── 1.4.0.md ├── 1.4.1.md ├── 1.4.2.md ├── 1.5.0.md ├── 1.5.1.md ├── 1.5.2.md ├── 1.6.0.md ├── 1.7.0.md ├── 1.7.1.md ├── 1.7.2.md ├── 1.8.0.md ├── 1.8.1.md ├── 1.9.0.md ├── 1.9.1.md ├── 1.9.2.md ├── 2.0.0.md ├── 2.0.1.md ├── 2.1.0.md └── 2.1.1.md ├── _users ├── eifer.md ├── nominatim.md ├── opencampingmap.md ├── osmcarto.md ├── parkraum.md └── thunderforest.md ├── about ├── features │ └── index.md ├── history │ ├── contributors.png │ └── index.md ├── index.md └── users │ ├── eifer.png │ ├── index.md │ ├── nominatim.png │ ├── opencampingmap.png │ ├── osmcarto.png │ ├── parkraum.png │ └── thunderforest.png ├── contribute ├── dependencies.md ├── how-osm2pgsql-processing-works.md ├── index.md ├── project-ideas.md └── road-map.md ├── css ├── main.scss └── ol.css ├── doc ├── community.md ├── faq.md ├── index.md ├── install.md ├── install │ ├── docker.md │ ├── freebsd.md │ ├── linux.md │ ├── macos.md │ ├── source.md │ └── windows.md ├── man │ ├── index.md │ ├── latest.md │ ├── osm2pgsql-replication-1.10.0.md │ ├── osm2pgsql-replication-1.11.0.md │ ├── osm2pgsql-replication-1.6.0.md │ ├── osm2pgsql-replication-1.7.1.md │ ├── osm2pgsql-replication-1.9.0.md │ ├── osm2pgsql-replication-1.9.1.md │ ├── osm2pgsql-replication-1.9.2.md │ ├── osm2pgsql-replication-2.0.0.md │ ├── osm2pgsql-replication-2.0.1.md │ ├── osm2pgsql-replication-2.1.0.md │ └── osm2pgsql-replication-2.1.1.md ├── manual-v1.html ├── manual.html └── tutorials │ ├── index.md │ └── switching-from-add-row-to-insert │ └── index.md ├── examples ├── 3dbuildings │ ├── 3dbuildings-manhatten.png │ ├── 3dbuildings-small.png │ ├── 3dbuildings.lua │ └── index.md ├── antarctica │ ├── antarctica.lua │ ├── antarctica1-small.png │ ├── antarctica1.png │ ├── antarctica2.png │ └── index.md ├── buildings │ ├── brasilia1.png │ ├── brasilia2-small.png │ ├── brasilia2.png │ ├── buildings.lua │ ├── create-building-example.sh │ └── index.md ├── export │ ├── export.svg │ └── index.md ├── index.md ├── poi-db │ ├── index.md │ ├── pois-berlin-small.png │ ├── pois-berlin.png │ └── pois.lua ├── raster-tiles │ ├── index.md │ └── tiles.png ├── raw-data-publication │ ├── data-symbol.svg │ ├── index.md │ ├── indian-restaurants.geojson │ ├── pg_featureserv.jpg │ └── restaurants.lua ├── road-length │ ├── highways.lua │ └── index.md └── vector-tiles │ ├── .gitignore │ ├── Brussels_signs.jpg │ ├── create-vector-tiles-example.sh │ ├── index.md │ ├── streets-of-brussels-small.png │ ├── streets-of-brussels.png │ └── streets.lua ├── favicon.ico ├── fonts ├── Mulish-Bold.woff ├── Mulish-Bold.woff2 ├── Mulish-Medium.woff ├── Mulish-Medium.woff2 ├── Mulish-MediumItalic.woff ├── Mulish-MediumItalic.woff2 ├── Mulish-Regular.woff └── Mulish-Regular.woff2 ├── generalization ├── PrototypeFund-P-Logo.svg ├── bmbf-logo.png └── index.md ├── img ├── apple.png ├── arch.svg ├── debian.svg ├── download.svg ├── fedora.svg ├── feed.svg ├── info.svg ├── infolink.svg ├── linux.png ├── logo-800.png ├── logo-outline.png ├── logo.png ├── mollweide.png ├── news │ └── 1000-stars.png ├── opensuse.svg ├── osm-help.png ├── osm2pgsql-overview.svg ├── plate-carree.jpg ├── postgis.png ├── postgresql.png ├── switch2osm.png ├── ubuntu.png ├── warning.svg ├── web-mercator.jpg ├── windows.png └── wip.png ├── index.md ├── js └── ol.js ├── news └── index.md ├── releases └── index.md ├── robots.txt ├── sponsors ├── fossgis.png ├── geofabrik.svg ├── index.md ├── osmfoundation.png └── sovereign_tech_fellowship.png ├── support └── index.md └── themepark ├── authors-manual.md ├── index.md └── users-manual.md /.gitignore: -------------------------------------------------------------------------------- 1 | _site 2 | .sass-cache 3 | contact.md 4 | download 5 | Gemfile.lock 6 | -------------------------------------------------------------------------------- /404.html: -------------------------------------------------------------------------------- 1 | --- 2 | layout: default 3 | title: Page not found 4 | --- 5 | 6 |
Sorry, we couldn't find the requested page.
9 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | 3 | # Hello! This is where you manage which Jekyll version is used to run. 4 | # When you want to use a different version, change it below, save the 5 | # file and run `bundle install`. Run Jekyll with `bundle exec`, like so: 6 | # 7 | # bundle exec jekyll serve 8 | # 9 | # This will help ensure the proper Jekyll version is running. 10 | # Happy Jekylling! 11 | gem "jekyll", "~> 3.8" 12 | gem "kramdown-parser-gfm" 13 | 14 | # This is the default theme for new Jekyll sites. You may change this to anything you like. 15 | gem "minima", "~> 2.0" 16 | 17 | # If you want to use GitHub Pages, remove the "gem "jekyll"" above and 18 | # uncomment the line below. To upgrade, run `bundle update github-pages`. 19 | # gem "github-pages", group: :jekyll_plugins 20 | 21 | # If you have any plugins, put them here! 22 | group :jekyll_plugins do 23 | gem "jekyll-feed", "~> 0.6" 24 | gem "jekyll-last-modified-at" 25 | end 26 | 27 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 28 | gem "tzinfo-data", platforms: [:mingw, :mswin, :x64_mingw, :jruby] 29 | 30 | # Performance-booster for watching directories on Windows 31 | gem "wdm", "~> 0.1.0" if Gem.win_platform? 32 | 33 | gem "webrick", "~> 1.8" 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Website osm2pgsql.org 3 | 4 | This is the source code for the website of the osm2pgsql software at 5 | [osm2pgsql.org](https://osm2pgsql.org). 6 | 7 | It is written using the static web site generator 8 | [Jekyll](https://jekyllrb.com/). 9 | 10 | ## Development 11 | 12 | The code is expected to be run on stable Debian using ruby packages from 13 | the distribution. To install the required packages run: 14 | 15 | ``` 16 | sudo apt install ruby ruby-bundler jekyll jekyll-theme-minima \ 17 | ruby-kramdown-parser-gfm ruby-jekyll-feed \ 18 | ruby-jekyll-last-modified-at 19 | ``` 20 | 21 | Then check out the repository and build the site: 22 | 23 | ``` 24 | git clone https://github.com/osm2pgsql-dev/osm2pgsql-website 25 | cd osm2pgsql-website 26 | touch contact.md 27 | bundle exec jekyll serve 28 | ``` 29 | 30 | You'll then have a local version running on `http://127.0.0.1:4000/`. 31 | 32 | You can also install the ruby packages from gems. Simply run 33 | `gem install bundler jekyll && bundle install` after checking out the code. 34 | Please make sure to not submit any accidental changes to the `Gemfile.lock` 35 | file in PRs, if you compile this way. 36 | 37 | ## Contributing 38 | 39 | Read https://osm2pgsql.org/contribute/ for more about helping out. 40 | 41 | ## Manpages 42 | 43 | To create the osm2pgsql-replication man page call (in the osm2pgsql repo): 44 | 45 | ``` 46 | groff -mandoc -Thtml man/osm2pgsql-replication.1 47 | ``` 48 | 49 | Copy the result into a page similar to `doc/man/osm2pgsql-replication-1.6.0.md` 50 | and add a link to `doc/man/index.md`. 51 | 52 | ## Icons 53 | 54 | Some icons are from [Ionicons](https://github.com/ionic-team/ionicons). 55 | 56 | -------------------------------------------------------------------------------- /_bin/check_ids_in_manual.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Check for non-unique ids in the manual 4 | # 5 | # Run `jekyll build` before calling this. 6 | # 7 | 8 | grep id= _site/doc/manual.html | cut -d\" -f2 | sort | uniq -c | grep -v 1 9 | 10 | -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | # Welcome to Jekyll! 2 | # 3 | # This config file is meant for settings that affect your whole blog, values 4 | # which you are expected to set up once and rarely edit after that. If you find 5 | # yourself editing this file very often, consider using Jekyll's data files 6 | # feature for the data you need to update frequently. 7 | # 8 | # For technical reasons, this file is *NOT* reloaded automatically when you use 9 | # 'bundle exec jekyll serve'. If you change this file, please restart the server process. 10 | 11 | # Site settings 12 | # These are used to personalize your new site. If you look in the HTML files, 13 | # you will see them accessed via {{ site.title }}, {{ site.email }}, and so on. 14 | # You can create any custom variable you would like, and they will be accessible 15 | # in the templates via {{ site.myvariable }}. 16 | title: osm2pgsql 17 | description: >- # this means to ignore newlines until "baseurl:" 18 | osm2pgsql 19 | baseurl: "" # the subpath of your site, e.g. /blog 20 | url: "https://osm2pgsql.org" 21 | github: 22 | repository_url: https://github.com/osm2pgsql-dev/osm2pgsql-website 23 | # 24 | # Build settings 25 | markdown: kramdown 26 | plugins: 27 | - jekyll-feed 28 | # 29 | # Exclude from processing. 30 | # The following items will not be processed, by default. Create a custom list 31 | # to override the default setting. 32 | exclude: 33 | - Gemfile 34 | - Gemfile.lock 35 | - node_modules 36 | - vendor/bundle/ 37 | - vendor/cache/ 38 | - vendor/gems/ 39 | - vendor/ruby/ 40 | - _manual-v1/options 41 | - _manual-v2/options 42 | 43 | feed: 44 | path: news/feed.xml 45 | collections: 46 | manpages: 47 | output: true 48 | permalink: doc/man/:name.html 49 | releases: 50 | output: true 51 | permalink: releases/:name.html 52 | manual-v1: 53 | output: false 54 | manual-v2: 55 | output: false 56 | posts: 57 | output: true 58 | permalink: /news/:year/:month/:day/:title:output_ext 59 | users: 60 | output: false 61 | dependencies: 62 | output: false 63 | defaults: 64 | - 65 | scope: 66 | path: "" 67 | values: 68 | layout: default 69 | - 70 | scope: 71 | path: "" 72 | type: releases 73 | values: 74 | layout: release 75 | - 76 | scope: 77 | path: "" 78 | type: manpages 79 | values: 80 | layout: manpage 81 | -------------------------------------------------------------------------------- /_data/dependencies.yml: -------------------------------------------------------------------------------- 1 | repositories: 2 | - id: debian_13 3 | name: Debian Testing 4 | date: (2025) 5 | gs: groupstart 6 | - id: debian_12 7 | name: Debian 12 Bookworm 8 | date: 2023-06-10 9 | - id: debian_11 10 | name: Debian 11 Bullseye 11 | date: 2021-08-14 12 | eol: 2026 13 | - id: debian_10 14 | name: Debian 10 Buster 15 | date: 2019-07-06 16 | eol: 2024 17 | - id: ubuntu_24_04 18 | name: Ubuntu 24.04 (Noble) 19 | date: 2024-04-25 20 | eol: 2029-06 21 | gs: groupstart 22 | - id: ubuntu_22_04 23 | name: Ubuntu 22.04 (Jammy) 24 | date: 2022-04-21 25 | eol: 2027-04 26 | - id: ubuntu_20_04 27 | name: Ubuntu 20.04 (Focal) 28 | date: 2020-04-23 29 | eol: 2025-04 30 | - id: fedora_rawhide 31 | name: Fedora Rawhide 32 | gs: groupstart 33 | - id: fedora_41 34 | name: Fedora 41 35 | date: 2024-10-29 36 | eol: 2025-11-19 37 | - id: fedora_40 38 | name: Fedora 40 39 | date: 2024-04-23 40 | eol: 2025-05-13 41 | - id: fedora_39 42 | name: Fedora 39 43 | date: 2023-11-07 44 | eol: 2024-11-12 45 | - id: fedora_38 46 | name: Fedora 38 47 | date: 2023-04-18 48 | eol: 2024-05-14 49 | - id: centos_8 50 | name: CentOS 8 51 | date: 2019-09-24 52 | eol: 2029-05-31 53 | gs: groupstart 54 | - id: homebrew 55 | name: Homebrew 56 | gs: groupstart 57 | packages: 58 | - osm2pgsql 59 | - postgresql 60 | - postgis 61 | - lua 62 | - cmake 63 | - gcc 64 | - llvm 65 | - python 66 | - boost 67 | - proj 68 | - catch 69 | - fmt 70 | - libosmium 71 | - protozero 72 | - pyosmium 73 | - nlohmann-json 74 | -------------------------------------------------------------------------------- /_includes/download.html: -------------------------------------------------------------------------------- 1 | 4 | -------------------------------------------------------------------------------- /_includes/examples.md: -------------------------------------------------------------------------------- 1 | 2 | These examples show some use cases of osm2pgsql and highlight some features. 3 | 4 |This is the "classical" job of osm2pgsql: Import OSM data into a 10 | database to create raster tiles from.
11 | 12 | 13 | 14 |Osm2pgsql imports OSM data using a very flexible configuration making 17 | it easy to generate any kind of vector tiles.
18 | 19 | 20 | 21 |Need only a few feature types? Import only what you need for a quick 24 | map.
25 | 26 | 27 | 28 |Osm2pgsql can use many different projections to fit the area covered 31 | and your use case.
32 | 33 | 34 | 35 |An osm2pgsql database is well-suited for geospatial analysis using 37 | the power of the PostGIS database extension.
38 | 39 | 40 | 41 |Use osm2pgsql to create a points-of-interest map.
44 | 45 | 46 | 47 |Use height information on OSM buildings to create a simple 3d map.
50 | 51 | 52 | 53 |Osm2pgsql and a database can be used as a step in exporting OSM data 56 | into many different GIS formats.
57 | 58 | 59 | 60 |The raw OSM data can be published via a web API using pg_featureserv
63 | 64 | 65 |{{ page.program }} {{ page.version }}
9 | 10 |Released: {{ page.date | date: "%Y-%m-%d" }}
9 | 10 |11 | Github release page {% include img/logo-github.svg %} 12 |
13 | 14 | {{ content }} 15 | 16 | {% if page.manpages %} 17 |Some highlights from the list of features.
24 | 25 | 26 |Osm2pgsql was created in 2006 and has seen a lot of development 28 | since then.
29 | 30 | 31 |Who is using osm2pgsql and what are they using it for?
33 | 34 |Distribution | 19 |Released | 20 |End of life | 21 | {%- for package in site.data.dependencies.packages -%} 22 |{{ package }} | 23 | {%- endfor -%} 24 |
---|---|---|---|
{{ repos.name }} | 30 |{{ repos.date }} | 31 |{{ repos.eol }} | 32 | {%- for package in site.data.dependencies.packages -%} 33 |- | 34 | {%- endfor -%} 35 |
Instructions for downloading and installing osm2pgsql on different architectures.
13 | 14 | 15 | 16 |The manual contains all the details about running the current osm2pgsql 19 | version 2.x.y.
20 | 21 | 22 | 23 |This is the manual for older versions of osm2pgsql (1.x.y).
26 | 27 | 28 | 29 |Tutorials help new and advanced users with specific tasks around 32 | osm2pgsql.
33 | 34 | 35 | 36 |The man pages have short overviews about running the osm2pgsql 39 | and osm2pgsql-replication commands.
40 | 41 | 42 | 43 |The FAQ is a list of frequently asked questions and answers.
46 | 47 | 48 | 49 |Blog posts, videos, and more on osm2pgsql from the community.
52 | 53 | 54 | 55 |All releases with release notes and download links.
58 | 59 | 60 |If you want to set up a whole rendering toolchain to create maps from 72 | OSM data, you need more than just osm2pgsql. Have a look at switch2osm to 73 | get started.
74 | 75 | 76 | 77 |You'll need to understand how PostgreSQL works to make the most out of 80 | osm2pgsql. Understanding at least a bit of the SQL query language and 81 | something about PostgreSQL configuration is important.
82 | 83 | 84 | 85 |The PostGIS plugin extends the PostgreSQL database with geometry data 88 | types such as `POINT` or `POLYGON`, the geometry operations that manipulate 89 | those data types, and special geometry indexes.
90 | 91 | 92 |This man page is only available for newer versions of osm2pgsql.
28 | 29 | {% assign dev = site.manpages | where: "version", "Development version" | first -%} 30 |This man page is only available for newer versions of osm2pgsql.
45 | 46 | {% comment %} 47 | Create man pages with: groff -mandoc -Thtml man/osm2pgsql-replication.1 48 | {% endcomment %} 49 | 50 |17 | | {{ oc.appendix }} | 18 |
19 | {{ oc.title }}
20 | |
22 |
23 | {%- else -%}
24 |
26 | | {{ oc.chapter }} | 27 |
28 | {{ oc.title }}
29 | |
31 |
17 | | {{ oc.appendix }} | 18 |
19 | {{ oc.title }}
20 | |
22 |
23 | {%- else -%}
24 |
26 | | {{ oc.chapter }} | 27 |
28 | {{ oc.title }}
29 | |
31 |
Tutorials help new and advanced users with specific tasks around 8 | osm2pgsql.
9 | 10 | * [Switching from `add_row()` to `insert()`]({% link doc/tutorials/switching-from-add-row-to-insert/index.md %}) 11 | 12 | -------------------------------------------------------------------------------- /examples/3dbuildings/3dbuildings-manhatten.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osm2pgsql-dev/osm2pgsql-website/d6f82f6f649fa0b26027e6c2052e111db80cb6b0/examples/3dbuildings/3dbuildings-manhatten.png -------------------------------------------------------------------------------- /examples/3dbuildings/3dbuildings-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osm2pgsql-dev/osm2pgsql-website/d6f82f6f649fa0b26027e6c2052e111db80cb6b0/examples/3dbuildings/3dbuildings-small.png -------------------------------------------------------------------------------- /examples/3dbuildings/3dbuildings.lua: -------------------------------------------------------------------------------- 1 | 2 | local buildings = osm2pgsql.define_area_table('buildings', { 3 | -- Define an autoincrementing id column, QGIS likes a unique id on the table 4 | { column = 'id', sql_type = 'serial', create_only = true }, 5 | { column = 'height', type = 'real', not_null = true }, 6 | { column = 'geom', type = 'polygon', not_null = true }, 7 | }) 8 | 9 | -- calculate the height of the building from the tags 10 | function calc_height(tags) 11 | -- if an explicit 'height' tag is available use that 12 | -- could be extended to also allow height in feet 13 | if tags.height then 14 | local h = tonumber(tags.height) 15 | if h and h > 0 and h < 900 then 16 | return h 17 | end 18 | end 19 | 20 | -- use 'building:levels' tag and assume each level is 4 meters high 21 | local levels = tags['building:levels'] 22 | if levels then 23 | local l = tonumber(levels) 24 | if l and l > 0 and l < 200 then 25 | return l * 4 26 | end 27 | end 28 | 29 | -- fall back to default height if we can't find any useful tags 30 | return 12 31 | end 32 | 33 | function add_building(tags, geom) 34 | buildings:insert({ 35 | height = calc_height(tags), 36 | geom = geom 37 | }) 38 | end 39 | 40 | function osm2pgsql.process_way(object) 41 | if object.is_closed and object.tags.building then 42 | add_building(object.tags, object:as_polygon()) 43 | end 44 | end 45 | 46 | function osm2pgsql.process_relation(object) 47 | if object.tags.type == 'multipolygon' and object.tags.building then 48 | geom = object:as_multipolygon() 49 | for g in geom:geometries() do 50 | add_building(object.tags, g) 51 | end 52 | end 53 | end 54 | 55 | -------------------------------------------------------------------------------- /examples/3dbuildings/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | layout: examples 3 | title: 3D Building Map 4 | --- 5 | 6 |{{ post.date | date_to_string }}: | 13 |{{ post.title }} |