Minimap Creator is a HTTP server for creating minimaps.
- clone the project
- Run PsotGIS:
docker run --name minimap-postgis -p 5455:5432 -e POSTGRES_PASSWORD=snakeoil -e POSTGRES_HOST_AUTH_METHOD=trust --shm-size=1g -d postgis/postgis
- download map data sql and import it to PostGIS:
pigz -cd dump.sql.gz | psql -h localhost -p 5455 -U postgres
- save hillshading data as
data/hillshading-world.tif
- install dependencies
npm i
- build the project
npm run build
- start the server
PORT=8080 npm start
Query parameters, all are optional:
srs
- spatial reference system. Well supported are+init=epsg:3035
(good for Europe) and+init=epsg:3857
(global, default).lat
,lon
- pin latitude and longitude, default no pinwidth
- image width, default 800, or computed fromcountry
andheight
if specifiedheight
- image height, default 400, or computed fromcountry
andwidth
if specifiedscale
- global graphics scaling factor, default 1features
- comma separated features:roads
- roadsborders
- global borders (admin_level=2 for country borders, admin_level=4 for region borders); see https://wiki.openstreetmap.org/wiki/Tag:boundary=administrative#10_admin_level_values_for_specific_countriescoastlineBorders
- draw coastline border and mask maritime bordersscale
- map scalelimitPlacesToCountry
- show only places of specified countrytransliterate
- transliterate non-latin names
simplify
- line simplify (generalization) factor, default 2colors
- override default colors. Syntax:feature:color,feature:color,...
where feautre is one ofwater
,urban
,forest
,pin
,border
,coastline
,areaHighlight
,land
and color is HTML color.place-types
- which places to render, comma separated values of:city
,town
,village
. It can also contain a single valuecapital
to only display capitals.places
- which places to render, by OSM ID or by nameplace-label-placement
- label placements to try. Values:U
for up,D
for down,L
for left,R
for right. May be combination likeUDRL
. Default isU
.place-label-margin
- place labels margin, default20
.landcover-types
- what landcover to render, comma separated values of:forest
,water-body
,urban
.country
- country to zoom to and to highlightmajor-borders
- country codes and admin levels to show as major borders, format:cc:level,cc:level,...
; default:2
(admin_level=2
for every country)minor-borders
- country codes and admin levels to show as minor borders, format:cc:level,cc:level,...
micro-borders
- country codes and admin levels to show as micro borders, format:cc:level,cc:level,...
border-width-factor
- scale of the borders width, default 1coastline-width-factor
- scale of the coastline borders width, default equals toborder-width-factor
waterway-width-factor
- scale of the waterway width, default 1place-size-factor
- scale of the places, default 1highlight-admin-area
- OSM ID or name (local or slovak) of the area to highlighthillshading-opacity
- opacity of the hillshading in range from 0 (no shading, default) to 1 (full shading)hillshading-variant
- variant of the hillshading, defaultworld
watershed-name
- name of watershed to renderbbox
- explicit bounding box to render (minLon,minLat,maxLon,maxLat)margin
- map margin in pixels, default 5format
- output format, one ofpng
(default),jpeg
,svg
,pdf
Generated map must be enclosed with the following attribution: OpenStreetMap contributors (ODbL 1.0)
Highlight administrative area and show a marker:
curl 'http://localhost:8080?features=borders,landcover,roads&placeId=522422&country=sk&width=1200&scale=1&margin=20&minor-borders=hu:4,uk:4,at:4,pl:4,sk:4,cz:4µ-borders=sk:8&place-types=city,town&highlight-admin-area=Ko%C5%A1ick%C3%BD%20kraj&hillshading-opacity=0.5&lat=48.700142&lon=20.891184' | display
Watershed Hornád:
RIVER=hornad
curl "http://localhost:8080?features=borders,landcover,scale&width=1200&scale=2&place-size-factor=0.8&margin=20&place-types=city,town&hillshading-opacity=0.5&watershed-name=$RIVER&bbox="`ogrinfo -sql "select st_transform(st_envelope(st_union(geometry)), 4326) from watershed_$RIVER" data/watershed_$RIVER.sqlite watershed_$RIVER | grep Extent | sed -e 's/[^0-9\.]\{1,\}/,/g' | sed -e 's/^.\|.$//g'` | display
- Obtain latest planet.osm.pbf from planet.openstreetmap.org.
- Import the data:
imposm import -connection postgis://minimap:minimap@localhost/minimap -mapping mapping.yaml -read planet.osm.pbf -write -overwritecache imposm import -connection postgis://minimap:minimap@localhost/minimap -mapping mapping.yaml -deployproduction
- Process the data in PostGIS:
psql -h localhost minimap minimap < process.sql
- download simplified land polygons and convert it to PosgGIS SQL.
- Import
simplified_land_polygons.sql
to PosgGIS:psql -h localhost minimap minimap < simplified_land_polygons.sql
- Dump the data:
pg_dump -h localhost -U minimap -t simplified_land_polygons -t osm_admin_rels -t border_lines -t admin_borders -t osm_places -t roads -t landcover minimap | pigz > dump.sql.gz
- Run dockerized PostGIS:
docker run --name minimap-postgis -p 5455:5432 -e POSTGRES_PASSWORD=snakeoil -e POSTGRES_HOST_AUTH_METHOD=trust --shm-size=1g -d postgis/postgis
- Load data to dockerized PostGIS:
pigz -cd dump.sql | psql -h localhost -p 5455 -U postgres
Download geopackage(s) from https://land.copernicus.eu/imagery-in-situ/eu-hydro/eu-hydro-river-network-database?tab=download (for example EU-Hydro-Danube-GeoPackage)
Extract waterways of a watershed for a particular river - find its first and last segment object_id
and also for its parent.
- Hornád:
hornad danube RL35142907 RL35137645 RL35137675 RL35136997
- Dunajec:
dunajec vistula RL37002352 RL37004091 RL37004010 RL37004177
- Ipeľ:
ipel danube RL35140937 RL35122706 RL35122124 RL35122824
- Hron:
hron danube RL35142316 RL35122640 RL35122124 RL35122360
- Kysuca:
kysuca danube RL35131906 RL35131464 RL35131304 RL35131518
- Bečva:
becva danube RL35132213 RL35131855 RL35131847 RL35131675
- Berounka:
berounka elbe RL27008052 RL27009356 RL27009029 RL27009979
- Bobr:
bobr oder RL36000033 RL36003020 RL36003045 RL36003091
- Dyje:
dyje danube RL35128009 RL35127268 RL35127599 RL35126849
- Jihlava:
jihlava danube RL35130614 RL35128643 RL35128423 RL35128414
- Jizera:
jizera elbe RL27014232 RL27010591 RL27010611 RL27010903
- Bodrog:
bodrog danube RL35141164 RL35139123 RL35139542 RL35138716
scripts/gen_waterways.sh danube hornad RL35142907 RL35137645 RL35137675 RL35136997
Make watershed polygon (QGIS):
- Clip
- FlowAccumulationFullWorkflow
- ExtractStreams (100000)
- add point to sink
- Watershed
- Polygonize (gdal)
- SmoothVectors (10)
- Simplify (10)
- export to
data/watershed_{name}.sqlite
SELECT load_extension('mod_spatialite');
delete from admin_areas where ogc_fid = 785489; -- find ID of border making Krym Russian
insert into admin_areas select null, 1 as osm_id, name as name, name_sk, admin_level, country_code, st_union(geometry) as geometry from admin_areas where country_code = 'UA' and admin_level = 2 group by country_code;
delete from admin_areas where country_code = 'UA' and admin_level = 2 and osm_id <> 1;
- https://github.com/eurostat/RegionSimplify
- java -jar regionsimplify-1.4.1/RegionSimplify.jar -i admin.gpkg -s 9244649
- https://gis.stackexchange.com/questions/439271/simplify-multipolygon-removing-small-gaps-in-postgis/439274
- https://gadm.org/