I would like to render subset of OpenStreetMap features over big area into one image, no sub-tiles.
System: Devuan ascii 64bit (alike Debian 9), 64GB RAM, headless (SSH only)
There is what I already have
Map in .osm format (14GiB)
Installed and functional PostgreSQL 9.6.9 with the PostGIS extensions
osm2pgsql import went fine
osm2pgsql -s -d gis -C 22000 ./file.osm
`
psql gis
gis=# SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_relation_size(C.oid)) AS "size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_relation_size(C.oid) DESC
LIMIT 20;
public.planet_osm_nodes | 4048 MB
public.planet_osm_ways_nodes | 3718 MB
public.planet_osm_ways | 2003 MB
public.planet_osm_polygon | 1804 MB
public.planet_osm_nodes_pkey | 1666 MB
public.planet_osm_polygon_index | 638 MB
public.planet_osm_line | 539 MB
public.planet_osm_point | 282 MB
public.planet_osm_point_index | 187 MB
public.planet_osm_line_index | 187 MB
public.planet_osm_roads | 170 MB
public.planet_osm_ways_pkey | 157 MB
public.planet_osm_polygon_pkey | 122 MB
public.planet_osm_point_pkey | 75 MB
public.planet_osm_rels | 73 MB
pg_toast.pg_toast_45676 | 58 MB
public.planet_osm_rels_parts | 49 MB
pg_toast.pg_toast_45680 | 47 MB
public.planet_osm_line_pkey | 33 MB
pg_toast.pg_toast_45675 | 33 MB
Compiled Mapnik 3.0.20 and mapnik-python-3.0.x
Python script (source: https://wiki.openstreetmap.org/wiki/Mapnik/Rendering_OSM_XML_data_directly (changed to use psql instead of .osm))
`
#!/usr/bin/env python
from mapnik import *
mapfile = 'power.xml'
map_output = 'mymap.tiff'
m = Map(1*1024,1*1024)
load_map(m, mapfile)
bbox=(Envelope( 12.08,48.54,18.86,51.06 ))
m.zoom_to_box(bbox)
#print 'Scale = ' , m.scale()
render_to_file(m, map_output)
- power.xml (referenced from the Python script above)
`
<?xml version="1.0" encoding="utf-8"?>
<Map background-color="#ffffff" srs="+proj=latlong +datum=WGS84">
<FontSet name="book-fonts">
<Font face-name="DejaVu Sans Book" />
</FontSet>
<Style name="highways">
<Rule>
<Filter>[highway] <>''</Filter>
<LineSymbolizer stroke="#ff0000" stroke-width="2" stroke-linejoin="round"
stroke-linecap="round" />
</Rule>
<Rule>
<Filter>[highway] <>''</Filter>
<TextSymbolizer fontset-name="book-fonts" size="9" fill="#0000" halo-radiu
s="1" placement="line" />
</Rule>
</Style>
<Layer name="highways" status="on" srs="+proj=latlong +datum=WGS84">
<StyleName>highways</StyleName>
<Datasource>
<Parameter name="type">postgis</Parameter>
<Parameter name="host">localhost</Parameter>
<Parameter name="dbname">gis</Parameter>
<Parameter name="user">root</Parameter>
<Parameter name="table">(select highway from planet_osm_line) as road</Par
ameter>
<Parameter name="password">root</Parameter>
</Datasource>
</Layer>
</Map>
- Trying to render it:
`
python ./render.py
Segmentation fault
- Another method - nik4.py (source: https://github.com/Zverik/Nik4 ) is also failing miserably:
`
python ./nik4.py -c 15 50 -z 10 -d 1024 768 -f png256 ./mapnik_pt.xml ./image.png
Traceback (most recent call last):
File "./nik4.py", line 629, in <module>
run(options)
File "./nik4.py", line 395, in run
mapnik.load_map_from_string(m, style_xml.encode("utf-8"), False, style_path)
RuntimeError: Postgis Plugin: ERROR: column "line" does not exist
LINE 2: route='ferry' or line='ferry') as routes LIMIT 0
^
in executeQuery Full sql was: 'SELECT * FROM (select way, route from planet_osm_line where
route='ferry' or line='ferry') as routes LIMIT 0'
encountered during parsing of layer 'ferry-routes' in Layer
Already answered questions
- Does Envelope() match the .osm coordinates? Yes.
<bounds minlon="12.08477" minlat="48.54292" maxlon="18.86321" maxlat="51.06426" origin="0.41"/>
Any ideas what I made wrong? How are you rendering one-big-image maps?
If my way is completely wrong, please suggest better way. The ultimate goal is to render for example all roads and all rivers into one big image for A1 poster.
planet_osm_*
tables (you should probably check what mapniksload_map
/render_to_file
function expects exactly). – geozelot Aug 11 '18 at 21:25