GridSquares

class visigoth.map_layers.gridsquares.GridSquares(decimal_places=3, stroke='black', stroke_width=1, font_height=12, text_attributes={'fill': 'white'})

Draw grid squares with lon/lat labels

Keyword Arguments
  • decimal_places (int) – the number of decimal places to display in labels

  • stroke (str) – stroke colour for grid line

  • stroke_width (int) – width of grid line

  • font_height (int) – the grid label font size in pixels

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

Example

Screenshot (Link to open SVG for interactive features):

../_images/example29.png

Source Code (Link to Github):


import os.path
import sys
import argparse
import random

from visigoth import Diagram
from visigoth.map_layers.gridsquares  import GridSquares
from visigoth.map_layers.wms  import WMS

from visigoth.containers.map import Map
from visigoth.utils.mapping import Mapping

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 = ((-180.0,-75),(180.0,75))
    m = Map(512,bounds)
    m.addLayer(WMS())
    m.addLayer(GridSquares())
    d.add(m)
    svg = d.draw()

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