Package: mapmaker
Map Makermapmakeris a simple script to generate map images for “Slippy Tile” maps.
Map tiles are downloaded from services such as OpenStreetMap and are combined
into a single image.InstallationUse the installation script:$pythonsetup.pyinstallOr install using pip:$pipinstallmapmakerCommand Line UsageUsemapmaker--helpto show a detailed list of options.Basic UsageThis will create a filemap.pngin the current directory. The map will
cover the bounding box specified with two pairs of lat/lon coordinates:$mapmaker47.44,10.9547.37,11.13One can also specify a center point and a radius:$mapmaker63.0695,-151.0074100kmIf the coordinates start with a negative value, use--to indicate the
end of command line flags:$mapmaker---32.653197,-70.0112100kmCoordinates can also be specified in DMS format:$mapmaker"63°4'10.2'' N, 151°0'26.64'' W"4kmUse a single quote for minutes (')
and two single quotes ('') for seconds.
Note the quotes around the command line argument.You can also specify theoutput file(default ismap.png):$mapmaker63.0695,-151.0074100kmdenali.pngAdditional OptionsSpecify thezoom levelwith the--zoomflag. The default is 8.
Higher values mean more detail and result in larger map images.$mapmaker--zoom1263.0695,-151.0074100kmUse--styleto control thelookof the map:$mapmaker--stylehuman63.0695,-151.0074100kmUse the--shadingflag to overlay a hillshading layer over the map image.
Note that hillshading is not available for all regions.$mapmaker--shading45.83,6.88100kmNote that some map styles already come with hillshading.To control the resulting image format, use--aspect:$mapmaker--aspect16:945.83,6.88100kmThe aspect ratio is given in the formatW:H(e.g. 4:3 or 19:9).
The resulting map image will contain the given bounding box (or point w/ radius)
and max be extended to North/South or East/West to match the aspect ratio.
Note that theresolutionof the image depends on the--zoomfactor.DecorationsSet a headline with--title, specify optionalPLACEMENT,COLORandBORDERfollowed by the title string.
The title will be added to theMargin Areaand will force a margin that is
large enough to accommodate the title.PLACEMENT:one of the cardinal directions e.g.NW, NNW, N, NNE, NE, ....BORDER:a single integer value for the border width in in pixels.COLOR:RGB(A) tuple as a comma separated string, e.g. “255,0,0”.BACKGROUND:RGB(A) tuple as a comma separated string, e.g. “255,0,0”.$mapmaker--titleMyMap--45.83,6.88100km$mapmaker--titleNNWMyMap--45.83,6.88100km$mapmaker--titleNNW5MyMap--45.83,6.88100km$mapmaker--titleNNW5255,0,0MyMap--45.83,6.88100km$mapmaker--titleNNW5255,0,00,0,255MyMap--45.83,6.88100kmNote the ``–`` to indicate the end of non-positional arguments.Use--commentto add a comment in small print. Arguments are the same
as for--title:$mapmaker--commentMyComment45.83,6.88100km$mapmaker--commentSE200,200,200MyComment45.83,6.88100kmUse--marginand--backgroundto apply a border around the map.
Note that some decoration arguments will automatically add a margin area.marginis given in pixels as a single value (all sides),
a pair of two values (top/bottom and left/right)
or as four separate values for top, right, bottom, left (clockwise).$mapmaker--margin5045.83,6.88100km$mapmaker--margin204045.83,6.88100km$mapmaker--margin1015201545.83,6.88100kmbackgroundis given as a comma separated RGB(A) value:$mapmaker--background200,200,20045.83,6.88100km$mapmaker--background200,200,200,12845.83,6.88100kmThe--frameargument adds a border around the map content, that is between
the map and the (optional) margin area.framehas up to four optional parameters:WIDTH:The width in pixels, e.g. “8”.COLOR:The main color as an RGB(A) value, e.g. “0,0,0” (black).ALT_COLOR:The secondary color as an RGB(A) value, e.g. “255,255,255” (white).STYLE:The style, either “solid” or “coordinates”.Arguments can be supplied in any order.ALT_COLORis only needed for styles that feature alternating colors,
if two RGB(A) values are specified, the second is considered theALT_COLOR.All arguments are optional and if--frameis specified without arguments,
a default frame will be drawn.Examples:$mapmaker--frame45.83,6.88100km$mapmaker--frame1245.83,6.88100km$mapmaker--frame12255,0,045.83,6.88100km$mapmaker--frame12255,0,00,0,255coordinates45.83,6.88100km$mapmaker--framecoordinates45.83,6.88100kmUse--scaleto show a scale bar on the map.
Optional arguments for scale are:PLACEMENT:Where to place the scale, must be one of the map areas
(e.g “SW”).WIDTH:The width of the scale bar in pixels (e.g. “2”).COLOR:The color to use for the scale bar an label, e.g. “0,0,0”.LABEL:The label style, eitherdefaultornolabel.The label shows the size of the scale in meters or kilometers.Examples:$mapmaker--scale--45.83,6.88100km$mapmaker--scaleSE--45.83,6.88100km$mapmaker--scale1--45.83,6.88100km$mapmaker--scale120,120,120--45.83,6.88100km$mapmaker--scalenolabel--45.83,6.88100km$mapmaker--scaleSE1120,120,120nolabel--45.83,6.88100kmGeoJSONThe--geojsonoption can be used to drawGeoJSONobjects onto the map.The GeoJSON can contain additional attributes to control the color, line width,
etc. The additional attributes can be part of aGeometryor part of thepropertiesattribute of a parentFeature.
Have a look hat the module documentation to see which special attributes are
supported.{"type":"Feature","geometry":{"type":"Point","coordinates":[12.594474,55.691438]},"properties":{"symbol":"square","color":[10,147,150],"size":12}}You can also use anyGeometryobject directly:{"type":"Polygon","coordinates":[[8.612316,47.680632],[8.612316,47.676327],[8.617423,47.676327],[8.617423,47.680632]]"color":[60,9,108],"fill":[60,9,108,120]}The--geojsonoption supports a path to a JSON file or a JSON formatted
string.Create a GalleryUse the--galleryflag to render a set of maps, one for each available style.
In this case, you specify an output directory instead of a file (default is the
current directory).
This flag ignores the--styleparameter.ConfigurationThe configuration file is located at~/.config/mapmaker/config.iniStyles (Tile Servers)You can specify additional map styles like this:# ~/.config/mapmaker/config.ini[service.osm]osm=https://tile.openstreetmap.org/{z}/{x}/{y}.png[service.opentopo]subdomains=abctopo=https://{s}.tile.opentopomap.org/{z}/{x}/{y}.pngWhereosmortopoare the names of the style (as used in the--styleflag) and the URL is the URL pattern for downloading tiles.Section names can be chosen freely but have to start withservice..
Each section may contain the following reserved entries:[service.example]tile_size=512api_key=my-secret-api-keysubdomains=abcdefAny other entries are expected to be key/value pairs with URL patterns.
If notile_sizeis configured, the default size (256px) is used.The URL patternmustcontain three variables:z:zoom levelx:X-coordinate of the tiley:Y-coordinate of the tileSee for examplehttps://wiki.openstreetmap.org/wiki/Tiles.The URL may contain additional placeholders for an API Key (see below)
and a subdomain:topo        = https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png
                      ^^^
atlas = https://tile.thunderforest.com/atlas/{z}/{x}/{y}.png?apikey={api}
                                                                     ^^^AuthorizationAuthorization is needed for the following services:DomainTypeHomepagetile.thunderforest.comAPI Keyhttps://www.thunderforest.com/maps.geoapify.comAPI Keyhttps://www.geoapify.com/api.mapbox.comTokenhttps://mapbox.com/Most services offer a free plan for limited/non-commercial use. Check out the
URL from the table above.Once you have registered, place your API Keys in a config file like this:# ~/.config/mapmaker/config.ini[service.thunderforest]api_key=YOUR_API_KEY[service.geoapify]api_key=YOUR_API_KEY[service.mapbox]api_key=YOUR_API_KEYWhere[service.xxx]is the config section which defines the URLs for this
service.