openstreetmap / mapnik-stylesheets Goto Github PK
View Code? Open in Web Editor NEWMirror of the mapnik stylesheets formerly used on OpenStreetMap.org
Home Page: http://svn.openstreetmap.org/applications/rendering/mapnik/
Mirror of the mapnik stylesheets formerly used on OpenStreetMap.org
Home Page: http://svn.openstreetmap.org/applications/rendering/mapnik/
Old XML format Mapnik stylesheets for OpenStreetMap 'standard' style -------------------------------------------------------------------- This used to be the development location of the Mapnik stylesheets powering tile.openstreetmap.org however these XML format stylesheets have since be superceded by new CartoCSS format stylesheets which can be found here: https://github.com/gravitystorm/openstreetmap-carto These old XML stylesheets are still used on some other tile servers. This directory also holds an assortment of helpful utility scripts for working with Mapnik and the OSM Mapnik XML stylesheets. Scalable large-area serving is typically done using mod_tile * Code is located at http://svn.openstreetmap.org/applications/utils/mod_tile. * Rendering is done by the 'renderd' daemon (both a python and C++ version are available). However, the easiest way to start rendering Mapnik tiles is to use the 'generate_tiles.py' script located within this directory. Quick References ---------------- If you need additional info, please read: - http://wiki.openstreetmap.org/wiki/Mapnik If you are new to Mapnik see: - http://mapnik.org If you are looking for an old file that used to be here see the 'archive' directory. Required -------- Mapnik >= 2.0.0 | The rendering library * Built with the PostGIS plugin * http://trac.mapnik.org/wiki/Mapnik-Installation osm2pgsql trunk | Tool for importing OSM data into PostGIS * The latest trunk source is highly recommended * http://svn.openstreetmap.org/applications/utils/export/osm2pgsql Coastline Shapefiles * Download these locally * For more info see: http://wiki.openstreetmap.org/wiki/Mapnik * They come with Mapnik indexes pre-built (using shapeindex) Planet.osm data in PostGIS * An extract (recommended) or the whole thing - http://wiki.openstreetmap.org/wiki/Planet.osm * Import this into PostGIS with osm2pgsql Quickstart ---------- The goal is to customize the Mapnik stylesheets to your local setup, test rendering a few images, and then get set up to render tiles. First, make sure you have downloaded the coastlines shapefiles and have set up a postgis enabled database with osm data imported using osm2pgsql. See http://wiki.openstreetmap.org/wiki/Mapnik for more info. Then customize the xml entities (the files in the inc/ directory) which are used by the 'osm.xml' to your setup. You can either use the 'generate_xml.py' script or manually edit a few files inside the 'inc' directory. Finally try rendering a few maps using either 'generate_image.py', 'generate_tiles.py' or 'nik2img.py'. Downloading the Coastlines Shapefiles ------------------------------------- All these actions are regrouped in the script file get-coastlines.sh in this directory wget http://tile.openstreetmap.org/world_boundaries-spherical.tgz # (51M) wget http://tile.openstreetmap.org/processed_p.tar.bz2 # (391M) wget http://tile.openstreetmap.org/shoreline_300.tar.bz2 # (42M) wget http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/cultural/ne_10m_populated_places.zip # (1.5 MB) wget http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/cultural/ne_110m_admin_0_boundary_lines_land.zip # (44 KB) tar xzf world_boundaries-spherical.tgz # creates a 'world_boundaries' folder tar xjf processed_p.tar.bz2 -C world_boundaries tar xjf shoreline_300.tar.bz2 -C world_boundaries unzip -q ne_10m_populated_places.zip -d world_boundaries unzip -q ne_110m_admin_0_boundary_lines_land.zip -d world_boundaries Using generate_xml.py --------------------- To use the 'generate_xml.py' script simply run: ./generate_xml.py -h # note the optional and required parameters Most users will need to pass their database settings with something like: ./generate_xml.py --dbname osm --host 'localhost' --user postgres --port 5432 --password '' If that command works, then you are ready to render tiles! The script will also pick up ALLCAPS global environment settings (where they must have a 'MAPNIK" prefix): export MAPNIK_DBNAME=osm && export MAPNIK_HOST=localhost && ./generate_xml.py Note: Depending on your database configuration you may be able to leave empty values for parameters such as 'host', 'port', 'password', or even 'dbname'. Do do this can pass the '--accept-none' flag or empty strings: ./generate_xml.py --dbname osm --accept-none ./generate_xml.py --dbname osm --host '' --user '' --port '' --password '' Advanced users may want to create multiple versions of the Mapnik XML for various rendering scenarios, and this can be done using 'generate_xml.py' by passing the 'osm.xml' as an argument and then piping the resulting xml to a new file: ./generate_xml.py osm.xml > my_osm.xml Manually editing 'inc' files ---------------------------- To manually configure your setup you will need to work with the XML snippets in the 'inc' directory which end with 'template'. Copy them to a new file and strip off the '.template' extension. cp inc/datasource-settings.xml.inc.template inc/datasource-settings.xml.inc cp inc/fontset-settings.xml.inc.template inc/fontset-settings.xml.inc cp inc/settings.xml.inc.template inc/settings.xml.inc Then edit the settings variables (e.g. '%(value)s') in those files to match your configuration. Details can be found in each file. Stick with the recommended defaults unless you know better. Troubleshooting --------------- If trying to read the XML with Mapnik (or any of the python scripts included here that use Mapnik) fails with an error like `XML document not well formed` or `Entity 'foo' not defined`, then try running xmllint, which may provide a more detailed error to help you find the syntax problem in the XML (or its referenced includes): xmllint osm.xml --noout Not output from the above command indicates the stylesheet should be working fine. If you see an error like: `warning: failed to load external entity "inc/datasource-settings.xml.inc"` then this likely indicates that an include file is missing, which means that you forgot to follow the steps above to generate the needed includes on the fly either by using `generate_xml.py` or manually creating your inc files. Testing rendering ----------------- To generate a simple image of the United Kingdom use the 'generate_image.py' script. ./generate_image.py # will output and 'image.png' file... To try generating an image with the ability to zoom to different areas or output different formats then try loading the XML using nik2img. Download and install nik2img using the instructions from http://trac.mapnik.org/wiki/Nik2Img To zoom to the same area as generate_image.py but at level 4 do: nik2img.py osm.xml image.png --center -2.2 54.25 --zoom 4 Advanced users may want to change settings and dynamically view result of the re-generated xml. This can be accomplished by piping the XML to nik2img.py, for example: ./generate_xml.py osm.xml | nik2img.py test.png Or, zoom into a specific layer's extent (useful when using a regional OSM extract): ./generate_xml.py --estimate_extent true --dbname osm osm.xml --accept-none | nik2img.py --zoom-to-layer roads roads.png Rendering tiles --------------- You are now ready to test rendering tiles. Edit the 'bbox' inside 'generate_tiles.py' and run ./generate_tiles.py Alternatively, run ./polytiles.py --bbox X1 Y1 X2 Y2 Tiles will be written into 'tiles' directory. To see the list of all parameters, run this script without any. Files and Directories --------------------- all_tiles ?? convert OBSOLETE. Use customize-mapnik-map instead. customize-mapnik-map Run this script to convert osm-template.xml into osm.xml with your settings. generate_xml.py A script to help customize the osm.xml. Will read parameters from the users environment or via command line flags. Run ./generate_xml.py -h for usage and help. generate_image.py A script to generate a map image from OSM data using Mapnik. Will read mapping instructions from $MAPNIK_MAP_FILE (or 'osm.xml') and write the finished map to 'image.png'. You have to change the script to change the bounding box or image size. generate_tiles.py A script to generate map tiles from OSM data using Mapnik. Will read mapping instructions from $MAPNIK_MAP_FILE (or 'osm.xml') and write the finished maps to the $MAPNIK_TILE_DIR directory. You have to change the script to change the bounding boxes or zoom levels for which tiles are created. polytiles.py An advanced script to generate map tiles with Mapnik. Can produce png files, .mbtiles or just a list. Supports not only bboxes, but PostGIS polygons, .poly files and tile lists. Run the script without parameters to see the full list of options. install.txt An almost cut-and-paste documentation on how to use all this. legend.py Script for generating a simple legend from osm-template.xml, useful for visualizing existing styles and changes. mkshield.pl Perl script to generate highway shield images. You normally don't have to run this because prerendered images are already stored in the 'symbols' directory. openstreetmap-mapnik-data openstreetmap-mapnik-world-boundaries These directories contain the things needed to create Debian packages for OSM Mapnik stuff. osm-template.xml A template for the osm.xml file which contains the rules on how Mapnik should render data. osm.xml The file which contains the rules on how Mapnik should render data. You should generate your own version from the osm-template.xml file. osm2pgsl.py Older script to read OSM data into a PostgreSQL/PostGIS database. Use the newer C version in ../../utils/export/osm2pgsql instead! set-mapnik-env Used to customize the environment needed by the other Mapnik OSM scripts. setup_z_order.sql SQL commands to set up Z order for rendering. This is included in the C version of osm2pgsql in ../../utils/export/osm2pgsql, so you don't need this any more. symbols Directory with icons and highway shield images. zoom-to-scale.txt Comparison between zoom levels and the scale denominator numbers needed for the Mapnik Map file.
Is this project current at all in the light of openstreetmap-carto deployed on osm.org?
I have a problem while generating tiles with generate_tiles.py. It writes randomly "empty tiles" on the log during the process (zoom level 15). It seems that it is totally random and not connected to a geographic area (I loaded a full country pbf to postgis, and now generate tile to a subset). I use a slow hard disk, and run the Ubuntu on VM with more than 6 GB RAM, but it use only 2 CPU core (an old AMD Athlon X3). I checked these tiles and they are really empty.
Screenshot:
click here
I have added a wayside shrine to OSM just a while ago (http://www.openstreetmap.org/node/4460585378), it does not render. Its importance is nearly the same as wayside_cross, it could have the same rules (from which zoom to render, etc.)
i missed the railway-special-element "hump_yard" to split trains and create new train-combinations.
style: same like a normal railway or a service-rail.
Translate by google:
"A hill in a yard, over which runs a track. Freight cars are pushed over that hill, so they roll under its own power in the right track. If it is detected as a point on the track."
Golf fairways should be rendered differently from the golf green, but they are not, leading to handful of examples I have found of people tagging for the renderer.
I've just come over to castle ruins that were not in the map. I wanted to tag them but to my surprise they already are in the map, just not rendered in Mapnik.
The area: http://www.openstreetmap.org/#map=18/49.28095/16.07840
The ruins are tagged on a node with these tags:
historic=ruins
name=zřícenina hradu Dub
ruins=castle
source=gps
According to the Wiki page that should be okay. The "ruins=castle" is added by me just a while ago but it did not help anyway.
I see the osm.xml render subway station text & image use PointsSymbolizer ,TextSymbolizer ,why not just use ShieldSymbolizer ?
Currently if you tag a dam with waterway=dam on a closed way (the area that the dam occupies) no rendering at all is provided on Mapnik.
This is not consistent with the Wiki page [1] that suggest to tag dam on areas.
Can anyone repair this issue?
[1] http://wiki.openstreetmap.org/wiki/Tag:waterway%3Ddam
Thank you
Alberto
$ ./generate_xml.py --dbname osm --user postgres --password password --accept-none
{'dbname': 'osm', 'host': '', 'user': 'postgres', 'extent': '-20037508,-19929239,20037508,19929239', 'password': 'password', 'port': '', 'estimate_extent': 'false'}
Traceback (most recent call last):
File "./generate_xml.py", line 174, in
validate(blended,parser)
File "./generate_xml.py", line 90, in validate
if not os.path.exists(params['world_boundaries']):
KeyError: 'world_boundaries'
osm@NL-Map:~/mapnik-style$ python
Python 2.7.3 (default, Apr 20 2012, 22:39:59)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import os
os.path.exists('world_boundaries')
True
I think that the "blended" array (at line 173) isn't picking up the 'world_boundaries' properly.
The README file of the project didn't have a md extension, so github didn't show it good.
I think it would be beneficial if vending machines (especially e.g. for food or drinks) are also displayed in Mapnik.
Partly the vending machines replace small grocery stores, and since even dog excrement machines are displayed, I am strongly in favor of also displaying other vending machines, which - according to my impression in my area - are increasing strongly lately.
I have cloned mapnik-stylesheets
project.
I have installed python-mapnik
.
I have this error when running ./generate_image.py
:
RuntimeError: failed to initialize projection with: '&srs900913;' in Map of 'osm.xml'
Am I not meant to use this xml file?
RuntimeError: Unable to process some data while parsing '/home/arch/openstreetmap-carto/osm.xml':
* attribute 'maximum-scale-denominator' with value '25000000' at line 0
* attribute 'minimum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '50000' at line 0
* attribute 'maximum-scale-denominator' with value '25000000' at line 0
* attribute 'maximum-scale-denominator' with value '100000' at line 0
* attribute 'maximum-scale-denominator' with value '3000000' at line 0
* attribute 'minimum-scale-denominator' with value '200000' at line 0
* attribute 'maximum-scale-denominator' with value '200000' at line 0
* attribute 'maximum-scale-denominator' with value '1000000000' at line 0
* attribute 'minimum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '25000000' at line 0
* attribute 'maximum-scale-denominator' with value '25000000' at line 0
* attribute 'maximum-scale-denominator' with value '50000' at line 0
* attribute 'maximum-scale-denominator' with value '100000' at line 0
* attribute 'maximum-scale-denominator' with value '100000' at line 0
* attribute 'maximum-scale-denominator' with value '50000' at line 0
* attribute 'maximum-scale-denominator' with value '200000' at line 0
* attribute 'maximum-scale-denominator' with value '200000' at line 0
* attribute 'maximum-scale-denominator' with value '5000' at line 0
* attribute 'maximum-scale-denominator' with value '200000' at line 0
* attribute 'maximum-scale-denominator' with value '50000' at line 0
* attribute 'maximum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '3000000' at line 0
* attribute 'maximum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '50000' at line 0
* attribute 'maximum-scale-denominator' with value '100000' at line 0
* attribute 'maximum-scale-denominator' with value '12500' at line 0
* attribute 'maximum-scale-denominator' with value '3000000' at line 0
* attribute 'maximum-scale-denominator' with value '25000' at line 0
* attribute 'maximum-scale-denominator' with value '50000' at line 0
* attribute 'maximum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '50000' at line 0
* attribute 'maximum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '25000' at line 0
* attribute 'maximum-scale-denominator' with value '200000' at line 0
* attribute 'maximum-scale-denominator' with value '12500000' at line 0
* attribute 'minimum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '200000' at line 0
* attribute 'maximum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '400000' at line 0
* attribute 'maximum-scale-denominator' with value '2500' at line 0
* attribute 'maximum-scale-denominator' with value '400000' at line 0
* attribute 'maximum-scale-denominator' with value '500000000' at line 0
* attribute 'minimum-scale-denominator' with value '50000000' at line 0
* attribute 'maximum-scale-denominator' with value '50000000' at line 0
* attribute 'minimum-scale-denominator' with value '400000' at line 0
* attribute 'maximum-scale-denominator' with value '400000' at line 0
* attribute 'minimum-scale-denominator' with value '100000' at line 0
* attribute 'maximum-scale-denominator' with value '100000' at line 0
* attribute 'maximum-scale-denominator' with value '12500' at line 0
* attribute 'maximum-scale-denominator' with value '50000' at line 0
* attribute 'maximum-scale-denominator' with value '3000000' at line 0
* attribute 'maximum-scale-denominator' with value '12500' at line 0
* attribute 'maximum-scale-denominator' with value '200000000' at line 0
* attribute 'maximum-scale-denominator' with value '100000000' at line 0
* attribute 'minimum-scale-denominator' with value '12500' at line 0
* attribute 'maximum-scale-denominator' with value '50000000' at line 0
* attribute 'maximum-scale-denominator' with value '50000000' at line 0
* attribute 'minimum-scale-denominator' with value '12500' at line 0
* attribute 'maximum-scale-denominator' with value '200000' at line 0
* attribute 'maximum-scale-denominator' with value '200000' at line 0
* attribute 'maximum-scale-denominator' with value '400000' at line 0
* attribute 'maximum-scale-denominator' with value '400000' at line 0
* attribute 'maximum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '12500' at line 0
* attribute 'maximum-scale-denominator' with value '50000' at line 0
* attribute 'maximum-scale-denominator' with value '750000' at line 0
* attribute 'minimum-scale-denominator' with value '100000' at line 0
* attribute 'maximum-scale-denominator' with value '100000' at line 0
* attribute 'maximum-scale-denominator' with value '25000' at line 0
* attribute 'maximum-scale-denominator' with value '100000' at line 0
* attribute 'maximum-scale-denominator' with value '25000' at line 0
* attribute 'maximum-scale-denominator' with value '400000' at line 0
* attribute 'maximum-scale-denominator' with value '25000' at line 0
* attribute 'maximum-scale-denominator' with value '1000000000' at line 0
* attribute 'minimum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '750000' at line 0
* attribute 'maximum-scale-denominator' with value '50000' at line 0
* attribute 'maximum-scale-denominator' with value '5000' at line 0
* attribute 'maximum-scale-denominator' with value '5000' at line 0
* attribute 'maximum-scale-denominator' with value '100000' at line 0
* attribute 'maximum-scale-denominator' with value '100000' at line 0
* attribute 'maximum-scale-denominator' with value '400000' at line 0
* attribute 'maximum-scale-denominator' with value '100000' at line 0
* attribute 'maximum-scale-denominator' with value '50000' at line 0
* attribute 'maximum-scale-denominator' with value '5000' at line 0
I have read many places that mapnik will generate tiles faster if the tile cover a larger map area.
So instead of producing png tiles that are 256x256 pixlels (BASETILE), mapnik can (I believe) produce meta tiles (png) which consist of e.g. 4 (BASETILE's) so the resulting meta tile is 512 x 512 pixels. I have also read many places that instead of generating 2x2 meta tiles, one can produce e.g. 4 x 4 or 8 x 8 meta tiles - which will speed up the generation of the tiles even more.
Would appreciate if someone could explain how this can be done - when using generate_tiles.py, and eventually a modified version of mapnik (if needed). After the generation of the meta tiles, it would be needed to split the meta tiles into "normal" tile size of 256 x 256 png files - with the correct directory structure and file names.
Is this repository capable of being synced up to the SVN repo? Are there any plans (please, god, I hope) to use 'just git' for this and not have to deal with SVN for this project?
It could useful if you can insert the extent as min-longitude, min‐latitude, max-longitude, max-latitude, as for osm2pgsql.
Hi, I am using the generate_image.py
script as I would like to generate some image files for printing.
I should emphasize that I barely know what I am doing: I don't work with GIS and I am winging it.
The problem I encountered is that, upon calling render
, some PostGIS function is called that does not exist:
Traceback (most recent call last):
File "/generate_image.py", line 70, in <module>
mapnik.render(m, im)
RuntimeError: Postgis Plugin: ERROR: function st_estimated_extent(unknown, unknown) does not exist
LINE 1: ..._YMin(ext),ST_XMax(ext),ST_YMax(ext) FROM (SELECT ST_Estimat...
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
in executeQuery Full sql was: 'SELECT ST_XMin(ext),ST_YMin(ext),ST_XMax(ext),ST_YMax(ext) FROM (SELECT ST_Estimated_Extent('planet_osm_polygon','way') as ext) as tmp'
This query, which returns the user functions
select n.nspname as function_schema,
p.proname as function_name,
l.lanname as function_language,
pg_get_function_arguments(p.oid) as function_arguments,
t.typname as return_type
from pg_proc p
left join pg_namespace n on p.pronamespace = n.oid
left join pg_language l on p.prolang = l.oid
left join pg_type t on t.oid = p.prorettype
where n.nspname not in ('pg_catalog', 'information_schema') and p.proname like '%estimate%extent%'
order by function_schema,
function_name;
returns
function_schema | function_name | function_language | function_arguments | return_type
-----------------+--------------------+-------------------+---------------------------+-------------
public | st_estimatedextent | c | text, text, text, boolean | box2d
public | st_estimatedextent | c | text, text, text | box2d
public | st_estimatedextent | c | text, text | box2d
(3 rows)
It seems that the function was renamed at some point in the past.
I was able to find a closed issue in the Mapnik repo but I am not sure how to take it from there.
Any help would be appreciated!
FYI, I am running on Windows 10, PostgreSQL 13 and PostGIS 3.1.0.
Hi!
Is it possible to change rendering of "proposed" features? IMHO: currrent version of "proposed" features is quite heavy. Sometimes it can take years (or decades) to build proposed railways or highways.
I suggest that proposed highways will be only dashlines as outerlines (no fill at all).
P
I installed a tile server based on this tutorial: https://ircama.github.io/osm-carto-tutorials/tile-server-ubuntu/
I strictly followed the instructions and I use Ubuntu 16.04.1 clean install.
The server works, but there is an error when I want to run generate_tiles.py.
"Runtime Error: Failed to find font face 'Noto Sans Adlam Regular' in FontSet 'fontset-0' in FontSet at line 17 of '/home/user/src/openstreetmap-carto/style.xml
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.