A project to re-implement the standard OpenStreetMap mapnik style, in CartoCSS
You need OpenStreetMap data loaded into a PostGIS database (see below for dependencies). These stylesheets currently work only with the osm2pgsql defaults (i.e. database name is 'gis', table names are 'planet_osm_point' etc).
It's probably easiest to grab an PBF of OSM data from metro.teczno.com or geofabrik. Once you've set up your PostGIS database, import with osm2pgsql:
osm2pgsql -d gis ~/path/to/data.osm.pbf
Additionally you need some shapefiles.
To download the shapefiles you can run the following script from this directory. No further steps should be needed as the data has been processed and placed in the requisite directories.
sh get-shapefiles.sh
You can also download them manually at the following paths:
shoreline_300.shp
downloadprocessed_p.shp
downloadbuiltup_area.shp
downloadne_110m_admin_0_boundary_lines_land.shp
downloadne_10m_populated_places_fixed.shp
download (and see below)
Put these shapefiles at path/to/opentreetmap-carto/data
The Natural Earth 2.0 populated places shapefile contains data that triggers a bug in mapnik. As a workaround we run the shapefile through ogr2ogr to clean up the data.
ogr2ogr ne_10m_populated_places_fixed.shp ne_10m_populated_places.shp
See mapnik/mapnik#1605 for more details.
- TileMill - This is a TileMill project you can copy (or symlink) directly into your Mapbox/project directory
If you aren't using TileMill, you can compile the CartoCSS stylesheets into Mapnik XML using the command-line carto
command.
- osm2pgsql to import your data into a PostGIS database
- PostgreSQL
- PostGIS
- ogr2ogr command line GDAL utility for processing vector data. here we use it to work around a encoding bug in the Nautral Earth data.
- unzip for decompressing downloaded files
This will be the full re-implementation of the OSM style. At this point development will branch - any bugfixes or features that didn't make 1.0 will appear in the 1.x series.
There are a number of refactorings that can be made to the style, either to fix glitches with the current style, or to leverage new features in carto / mapnik to simplify the stylesheets with only small changes to the output. It's also appropriate to pull out some of the 'old-skool' tagging methods that are now rarely used.
Care will be taken to not get too clever with variables and expressions. While these often make it easier to customise, experience has shown that over-cleverness (e.g. interpolated entities) can discourage contributions.
The end goal will be a style that hews close to the current look of the standard style, but is much more suitable for further development, and/or forking for third-parties to customise.
There are over 400 open requests on trac, some that have been open for years. These need reviewing and dividing into obvious fixes, or additional new features that need some cartographic judgement. The work done in v1.0 and v2.0 will make it much easier to process these.
- Always specify zoom levels as either >= or < . Don't use = or =< or >
- Open curly braces on the same line, and close on an empty line.
- One space before and after = etc
- Two space indents. No tabs.
- space after : but no before
- If there is a
&minscale_zoom18;
, ignore it. These really mess up any attempts to run the style at z19 - Dashes, not underscores, in layer names
- Avoid restating defaults, e.g. don't add
point-allow-overlap = false