Ruler

class visigoth.map_layers.ruler.Ruler(label='', decimal_places=2, stroke='black', stroke_width=2, font_height=16, text_attributes={})

Construct a map layer to display a ruler

Keyword Arguments
  • label (str) – label for ruler

  • decimal_places (int) – the number of decimal places to display

  • stroke (str) – stroke colour for axis line

  • stroke_width (int) – width of axis line

  • font_height (int) – the font size in pixels

  • text_attributes (dict) – a dict containing SVG name/value pairs

Example

Screenshot (Link to open SVG for interactive features):

../_images/example33.png

Source Code (Link to Github):


import os.path
import sys
import argparse
import random

from visigoth import Diagram
from visigoth.containers.map import Map
from visigoth.map_layers.wms  import WMS
from visigoth.map_layers.ruler  import Ruler
from visigoth.utils.mapping import Mapping
from visigoth.containers.box import Box
from visigoth.common.text import Text


if __name__ == "__main__":

    parser = argparse.ArgumentParser()
    parser.add_argument("--outpath", help="path for output SVG", default="example.svg")
    args = parser.parse_args()

    d = Diagram(fill="white")

    bounds = ((166.509144322, -46.641235447),(178.517093541, -34.4506617165))

    m = Map(512,bounds,zoom_to=4)
    # m.addLayer(WMS(layers=["osm_3857"]))
    m.addLayer(Ruler())
    d.add(Box(m))

    svg = d.draw()

    f = open(args.outpath, "wb")
    f.write(svg)
    f.close()