PostgreSQL postgis: Difference between revisions
Appearance
No edit summary |
|||
(8 intermediate revisions by the same user not shown) | |||
Line 14: | Line 14: | ||
create another, and use directory /opt/data | create another, and use directory /opt/data | ||
psql -d osm | psql -d osm | ||
CREATE DATABASE osm2; | |||
\c osm2 | |||
CREATE EXTENSION postgis; | CREATE EXTENSION postgis; | ||
CREATE ROLE osm; | |||
ALTER DATABASE osm2 OWNER TO osm; | ALTER DATABASE osm2 OWNER TO osm; | ||
\q | |||
cd /opt/data | cd /opt/data | ||
wget https://download.geofabrik.de/europe/germany/brandenburg-latest.osm.pbf | wget https://download.geofabrik.de/europe/germany/brandenburg-latest.osm.pbf | ||
Line 28: | Line 29: | ||
-------------+----------+----------+-----------------+-------------+-------------+------------+-----------+-----------------------+---------+------------+-------------------------------------------- | -------------+----------+----------+-----------------+-------------+-------------+------------+-----------+-----------------------+---------+------------+-------------------------------------------- | ||
osm2 | osmuser | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | | | 4771 MB | pg_default | | osm2 | osmuser | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | | | 4771 MB | pg_default | | ||
==Berlin== | |||
CREATE DATABASE osmdeber; | |||
\c osmdeber | |||
osmdeber=# ALTER DATABASE osmdeber OWNER TO osm; | |||
wget -O berlin-latest.osm.pbf https://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf | |||
osm2pgsql -d osmdeber -s berlin-latest.osm.pbf //osm2pgsql took 608s (10m 8s) overall. | |||
CREATE DATABASE osmdeberhs; | |||
\c osmdeberhs | |||
ALTER DATABASE osmdeberhs OWNER TO osm; | |||
CREATE EXTENSION postgis; | |||
CREATE EXTENSION hstore; |
Latest revision as of 2025-08-26T21:32:39
Example for Ubuntu and osmdb
apt install postgis sudo -u postgres createuser osmuser sudo -u postgres createdb --encoding=UTF8 --owner=osmuser osm sudo -u postgres psql osm --command='CREATE EXTENSION postgis;' psql -d osm SELECT PostGIS_Version(); //verify install quit; apt install osm2pgsql //https://osm2pgsql.org/doc/install/linux.html
wget https://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf osm2pgsql -d osm -s berlin-latest.osm.pbf //osm2pgsql took 302s (5m 2s) overall.
create another, and use directory /opt/data
psql -d osm CREATE DATABASE osm2; \c osm2 CREATE EXTENSION postgis; CREATE ROLE osm; ALTER DATABASE osm2 OWNER TO osm; \q cd /opt/data wget https://download.geofabrik.de/europe/germany/brandenburg-latest.osm.pbf osm2pgsql -d osm2 -s brandenburg-latest.osm.pbf
\l+ List of databases Name | Owner | Encoding | Locale Provider | Collate | Ctype | ICU Locale | ICU Rules | Access privileges | Size | Tablespace | Description -------------+----------+----------+-----------------+-------------+-------------+------------+-----------+-----------------------+---------+------------+-------------------------------------------- osm2 | osmuser | UTF8 | libc | en_US.UTF-8 | en_US.UTF-8 | | | | 4771 MB | pg_default |
Berlin
CREATE DATABASE osmdeber; \c osmdeber osmdeber=# ALTER DATABASE osmdeber OWNER TO osm;
wget -O berlin-latest.osm.pbf https://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf osm2pgsql -d osmdeber -s berlin-latest.osm.pbf //osm2pgsql took 608s (10m 8s) overall.
CREATE DATABASE osmdeberhs; \c osmdeberhs ALTER DATABASE osmdeberhs OWNER TO osm; CREATE EXTENSION postgis; CREATE EXTENSION hstore;