Last active
November 19, 2019 17:54
-
-
Save Gro-Tsen/551746890d8ec9d22b10f9df13244f2d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## This is for Ubuntu 18.04 "Bionic Beaver": | |
## Install postgresql-10=10.10-0ubuntu0.18.04.1 and postgis=2.4.3+dfsg-4 | |
## (which will install postgresql-10-postgis-2.4=2.4.3+dfsg-4 as dependency). | |
## DO NOT install osm2pgsql=0.94.0+ds-1 as it seems too old (will compile below). | |
#### Compilation of osm2pgsql #### | |
## Install libboost-filesystem1.65-dev andlibboost-system1.65-dev before this. | |
cd /data/misc | |
wget -O osm2pgsql-1.2.0.tar.gz https://github.com/openstreetmap/osm2pgsql/archive/1.2.0.tar.gz | |
cd /usr/local/src | |
zcat /data/misc/osm2pgsql-1.2.0.tar.gz | tar xf - | |
cd osm2pgsql-1.2.0 | |
mkdir build | |
cd build | |
cmake -DCMAKE_INSTALL_PREFIX:PATH=/opt/osm2pgsql-1.2.0 .. | |
make -j24 | |
sudo mkdir /opt/osm2pgsql-1.2.0 | |
sudo chown $USER /opt/osm2pgsql-1.2.0 | |
make install | |
chmod -R a+rX,go-w,ug-s /opt/osm2pgsql-1.2.0 | |
sudo chown -R bin:root /opt/osm2pgsql-1.2.0 | |
## Using a version of NodeJS installed into /opt/node-v10 (not sure if useful). | |
PATH=/opt/node-v10/bin:$PATH | |
PATH=/opt/osm2pgsql-1.2.0/bin:$PATH | |
export PATH | |
#### Get openstreetmap-carto (style) #### | |
cd /work/tmp | |
git clone https://github.com/gravitystorm/openstreetmap-carto.git | |
#### Alter style to avoir displaying hospitals at zoomlevel 15 #### | |
cd /work/tmp | |
cd openstreetmap-carto | |
patch -p1 << '__EOF__' | |
diff --git a/amenity-points.mss b/amenity-points.mss | |
index a040ff7..0350b37 100644 | |
--- a/amenity-points.mss | |
+++ b/amenity-points.mss | |
@@ -593,7 +593,7 @@ | |
marker-clip: false; | |
} | |
- [feature = 'amenity_hospital'][zoom >= 15] { | |
+ [feature = 'amenity_hospital'][zoom >= 16] { | |
marker-file: url('symbols/amenity/hospital.svg'); | |
marker-fill: @health-color; | |
marker-clip: false; | |
@@ -815,7 +815,7 @@ | |
marker-clip: false; | |
} | |
- [feature = 'historic_castle'][castle_type != 'stately'][castle_type != 'manor'][zoom >= 15], | |
+ [feature = 'historic_castle'][castle_type != 'stately'][castle_type != 'manor'][zoom >= 16], | |
[feature = 'historic_castle'][castle_type = 'stately'][zoom >= 16], | |
[feature = 'historic_castle'][castle_type = 'manor'][zoom >= 16], | |
[feature = 'historic_manor'][zoom >= 16] { | |
@@ -1439,7 +1439,7 @@ | |
[feature = 'amenity_bicycle_parking'], | |
[feature = 'amenity_motorcycle_parking'], | |
[feature = 'amenity_parking_entrance'] { | |
- [zoom >= 14][way_pixels > 750], | |
+ [zoom >= 16][way_pixels > 750], | |
[zoom >= 17][feature = 'amenity_parking'], | |
[zoom >= 18] { | |
[feature = 'amenity_parking'] { marker-file: url('symbols/amenity/parking.svg'); } | |
__EOF__ | |
#### Convert openstreetmap-carto style into Mapnik XML style using CartoCSS #### | |
cd /work/tmp | |
npm install carto | |
node node_modules/carto/bin/carto openstreetmap-carto/project.mml > openstreetmap-carto/osm.xml | |
#### Get OSM data #### | |
cd /work/tmp | |
wget https://download.geofabrik.de/europe/france-latest.osm.bz2 | |
## File is about 5.5GB in size | |
#### Create database and set up for use with PostGIS #### | |
sudo -u postgres createuser -d $USER | |
createdb gis | |
sudo -u postgres psql -d gis -c 'CREATE EXTENSION postgis;' | |
sudo -u postgres psql -d gis -c 'CREATE EXTENSION hstore;' | |
#### Import OSM data into PostGIS database #### | |
/opt/osm2pgsql-1.2.0/bin/osm2pgsql -G --hstore --style openstreetmap-carto/openstreetmap-carto.style --tag-transform-script openstreetmap-carto/openstreetmap-carto.lua -d gis -C 6400 france-latest.osm.bz2 | |
## Expect ~410953k nodes, ~59941k ways, ~583k relations | |
## (takes about 6 hours on a 2.1GHz Xeon with 32GB RAM). | |
## Maybe not do this? Probably not useful | |
psql -d gis -f openstreetmap-carto/indexes.sql | |
psql -d gis -c 'CREATE INDEX planet_osm_point_idx ON planet_osm_point ( osm_id ) ;' | |
psql -d gis -c 'CREATE INDEX planet_osm_line_idx ON planet_osm_line ( osm_id ) ;' | |
psql -d gis -c 'CREATE INDEX planet_osm_polygon_idx ON planet_osm_polygon ( osm_id ) ;' | |
psql -d gis -c 'CREATE INDEX planet_osm_roads_idx ON planet_osm_roads ( osm_id ) ;' | |
## Install nik4=1.6-3 for this: | |
cd openstreetmap-carto | |
nik4 -s 60000 --ppi 300 -a +4 -c 2.3489 48.8580 osm.xml ../paris-a4.png | |
nik4 -s 30000 --ppi 150 -a +2 -c 2.3489 48.8580 osm.xml ../paris-a2.png | |
nik4 -s 15000 --ppi 75 -a +0 -c 2.3489 48.8580 osm.xml ../paris-a0.png | |
nik4 -s 60000 --ppi 600 -a +4 -c 2.3489 48.8580 osm.xml ../paris-larger-a4.png | |
nik4 -s 30000 --ppi 300 -a +2 -c 2.3489 48.8580 osm.xml ../paris-larger-a2.png | |
nik4 -s 15000 --ppi 150 -a +0 -c 2.3489 48.8580 osm.xml ../paris-larger-a0.png | |
nik4 -s 300000 --ppi 300 -a +4 -c 2.3489 48.8580 osm.xml ../region-a4.png | |
nik4 -s 150000 --ppi 150 -a +2 -c 2.3489 48.8580 osm.xml ../region-a2.png | |
nik4 -s 75000 --ppi 75 -a +0 -c 2.3489 48.8580 osm.xml ../region-a0.png | |
nik4 -s 300000 --ppi 600 -a +4 -c 2.3489 48.8580 osm.xml ../region-larger-a4.png | |
nik4 -s 150000 --ppi 300 -a +2 -c 2.3489 48.8580 osm.xml ../region-larger-a2.png | |
nik4 -s 75000 --ppi 150 -a +0 -c 2.3489 48.8580 osm.xml ../region-larger-a0.png |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See https://twitter.com/gro_tsen/status/1195667406686969856 for some context.