# pycoast.cw_agg module

ContourWriter based on the aggdraw library.

class pycoast.cw_agg.ContourWriterAGG(db_root_path=None)

  Bases: `ContourWriterBase`

  Adds countours from GSHHS and WDBII to images using the AGG engine for high quality images.

  Parameters:
    db_root_pathstr

      Path to root dir of GSHHS and WDBII shapefiles

  add_borders(image, area_def, resolution='c', level=1, outline='white', width=1, outline_opacity=255, x_offset=0, y_offset=0)

    Add borders to a PIL image object.

    Parameters:
      imageobject

        PIL image object

      proj4_stringstr

        Projection of area as Proj.4 string

      area_extentlist

        Area extent as a list (LL_x, LL_y, UR_x, UR_y)

      resolutionstr, optional {‘c’, ‘l’, ‘i’, ‘h’, ‘f’}

        Dataset resolution to use

      levelint, optional {1, 2, 3}

        Detail level of dataset

      outlinestr or (R, G, B), optional

        Border color

      widthfloat, optional

        Width of coastline

      outline_opacityint, optional {0; 255}

        Opacity of coastline color

      x_offsetfloat, optional

        Pixel offset in x direction

      y_offsetfloat, optional

        Pixel offset in y direction

  add_borders_to_file(filename, area_def, resolution='c', level=1, outline='white', width=1, outline_opacity=255, x_offset=0, y_offset=0)

    Add borders to an image file. The resulting image is in ‘RGBA’ mode.

    Parameters:
      imageobject

        Image file

      proj4_stringstr

        Projection of area as Proj.4 string

      area_extentlist

        Area extent as a list (LL_x, LL_y, UR_x, UR_y)

      resolutionstr, optional {‘c’, ‘l’, ‘i’, ‘h’, ‘f’}

        Dataset resolution to use

      levelint, optional {1, 2, 3}

        Detail level of dataset

      outlinestr or (R, G, B), optional

        Border color

      widthfloat, optional

        Width of coastline

      outline_opacityint, optional {0; 255}

        Opacity of coastline color

      x_offsetfloat, optional

        Pixel offset in x direction

      y_offsetfloat, optional

        Pixel offset in y direction

  add_coastlines(image, area_def, resolution='c', level=1, fill=None, fill_opacity=255, outline='white', width=1, outline_opacity=255, x_offset=0, y_offset=0)

    Add coastlines to a PIL image object.

    Parameters:
      imageobject

        PIL image object

      proj4_stringstr

        Projection of area as Proj.4 string

      area_extentlist

        Area extent as a list (LL_x, LL_y, UR_x, UR_y)

      resolutionstr, optional {‘c’, ‘l’, ‘i’, ‘h’, ‘f’}

        Dataset resolution to use

      levelint, optional {1, 2, 3, 4}

        Detail level of dataset

      fillstr or (R, G, B), optional

        Land color

      fill_opacityint, optional {0; 255}

        Opacity of land color

      outlinestr or (R, G, B), optional

        Coastline color

      widthfloat, optional

        Width of coastline

      outline_opacityint, optional {0; 255}

        Opacity of coastline color

      x_offsetfloat, optional

        Pixel offset in x direction

      y_offsetfloat, optional

        Pixel offset in y direction

  add_coastlines_to_file(filename, area_def, resolution='c', level=1, fill=None, fill_opacity=255, outline='white', width=1, outline_opacity=255, x_offset=0, y_offset=0)

    Add coastlines to an image file. The resulting image is in ‘RGBA’ mode.

    Parameters:
      filenamestr

        Image file

      proj4_stringstr

        Projection of area as Proj.4 string

      area_extentlist

        Area extent as a list (LL_x, LL_y, UR_x, UR_y)

      resolutionstr, optional {‘c’, ‘l’, ‘i’, ‘h’, ‘f’}

        Dataset resolution to use

      levelint, optional {1, 2, 3, 4}

        Detail level of dataset

      fillstr or (R, G, B), optional

        Land color

      fill_opacityint, optional {0; 255}

        Opacity of land color

      outlinestr or (R, G, B), optional

        Coastline color

      widthfloat, optional

        Width of coastline

      outline_opacityint, optional {0; 255}

        Opacity of coastline color

      x_offsetfloat, optional

        Pixel offset in x direction

      y_offsetfloat, optional

        Pixel offset in y direction

  add_grid(image, area_def, Dlonlat, dlonlat, font=None, write_text=True, fill=None, fill_opacity=255, outline='white', width=1.0, outline_opacity=255, minor_outline='white', minor_width=0.5, minor_outline_opacity=255, minor_is_tick=True, lon_placement='tb', lat_placement='lr')

    Add a lon-lat grid to a PIL image object.

    Parameters:
      imageobject

        PIL image object

      proj4_stringstr

        Projection of area as Proj.4 string

      Dlonlat: (float, float)

        Major grid line separation

      dlonlat: (float, float)

        Minor grid line separation

      font: Aggdraw Font object, optional

        Font for major line markings

      write_textboolean, optional

        Determine if line markings are enabled

      fill_opacityint, optional {0; 255}

        Opacity of text

      outlinestr or (R, G, B), optional

        Major line color

      widthfloat, optional

        Major line width

      outline_opacityint, optional {0; 255}

        Opacity of major lines

      minor_outlinestr or (R, G, B), optional

        Minor line/tick color

      minor_widthfloat, optional

        Minor line width

      minor_outline_opacityint, optional {0; 255}

        Opacity of minor lines/ticks

      minor_is_tickboolean, optional

        Use tick minor line style (True) or full minor line style (False)

  add_grid_to_file(filename, area_def, Dlonlat, dlonlat, font=None, write_text=True, fill=None, fill_opacity=255, outline='white', width=1, outline_opacity=255, minor_outline='white', minor_width=0.5, minor_outline_opacity=255, minor_is_tick=True, lon_placement='tb', lat_placement='lr')

    Add a lon-lat grid to an image. The resulting image is in ‘RGBA’ mode.

    Parameters:
      imageobject

        PIL image object

      proj4_stringstr

        Projection of area as Proj.4 string

      Dlonlat: (float, float)

        Major grid line separation

      dlonlat: (float, float)

        Minor grid line separation

      font: Aggdraw Font object, optional

        Font for major line markings

      write_textboolean, optional

        Determine if line markings are enabled

      fill_opacityint, optional {0; 255}

        Opacity of text

      outlinestr or (R, G, B), optional

        Major line color

      widthfloat, optional

        Major line width

      outline_opacityint, optional {0; 255}

        Opacity of major lines

      minor_outlinestr or (R, G, B), optional

        Minor line/tick color

      minor_widthfloat, optional

        Minor line width

      minor_outline_opacityint, optional {0; 255}

        Opacity of minor lines/ticks

      minor_is_tickboolean, optional

        Use tick minor line style (True) or full minor line style (False)

  add_line(image, area_def, lonlats, fill=None, fill_opacity=255, outline='white', width=1, outline_opacity=255, x_offset=0, y_offset=0)

    Add a user defined poly-line from a list of (lon,lat) coordinates.

    Parameters:
      imageobject

        PIL image object

      area_deflist [proj4_string, area_extent]
        proj4_string : str
        Projection of area as Proj.4 string
        area_extent : list
        Area extent as a list (LL_x, LL_y, UR_x, UR_y)
      lonlatslist of lon lat pairs

        e.g. [(10,20),(20,30),…,(20,20)]

      outlinestr or (R, G, B), optional

        line color

      widthfloat, optional

        line width

      outline_opacityint, optional {0; 255}

        Opacity of lines

      x_offsetfloat, optional

        Pixel offset in x direction

      y_offsetfloat, optional

        Pixel offset in y direction

  add_polygon(image, area_def, lonlats, fill=None, fill_opacity=255, outline='white', width=1, outline_opacity=255, x_offset=0, y_offset=0)

    Add a user defined polygon from a list of (lon,lat) coordinates.

    Parameters:
      imageobject

        PIL image object

      area_deflist [proj4_string, area_extent]
        proj4_string : str
        Projection of area as Proj.4 string
        area_extent : list
        Area extent as a list (LL_x, LL_y, UR_x, UR_y)
      lonlatslist of lon lat pairs

        e.g. [(10,20),(20,30),…,(20,20)]

      fillstr or (R, G, B), optional

        Polygon fill color

      fill_opacityint, optional {0; 255}

        Opacity of polygon fill

      outlinestr or (R, G, B), optional

        line color

      widthfloat, optional

        line width

      outline_opacityint, optional {0; 255}

        Opacity of lines

      x_offsetfloat, optional

        Pixel offset in x direction

      y_offsetfloat, optional

        Pixel offset in y direction

  add_rivers(image, area_def, resolution='c', level=1, outline='white', width=1, outline_opacity=255, x_offset=0, y_offset=0)

    Add rivers to a PIL image object.

    Parameters:
      imageobject

        PIL image object

      proj4_stringstr

        Projection of area as Proj.4 string

      area_extentlist

        Area extent as a list (LL_x, LL_y, UR_x, UR_y)

      resolutionstr, optional {‘c’, ‘l’, ‘i’, ‘h’, ‘f’}

        Dataset resolution to use

      levelint, optional {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}

        Detail level of dataset

      outlinestr or (R, G, B), optional

        River color

      widthfloat, optional

        Width of coastline

      outline_opacityint, optional {0; 255}

        Opacity of coastline color

      x_offsetfloat, optional

        Pixel offset in x direction

      y_offsetfloat, optional

        Pixel offset in y direction

  add_rivers_to_file(filename, area_def, resolution='c', level=1, outline='white', width=1, outline_opacity=255, x_offset=0, y_offset=0)

    Add rivers to an image file. The resulting image is in ‘RGBA’ mode.

    Parameters:
      imageobject

        Image file

      proj4_stringstr

        Projection of area as Proj.4 string

      area_extentlist

        Area extent as a list (LL_x, LL_y, UR_x, UR_y)

      resolutionstr, optional {‘c’, ‘l’, ‘i’, ‘h’, ‘f’}

        Dataset resolution to use

      levelint, optional {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}

        Detail level of dataset

      outlinestr or (R, G, B), optional

        River color

      widthfloat, optional

        Width of coastline

      outline_opacityint, optional {0; 255}

        Opacity of coastline color

      x_offsetfloat, optional

        Pixel offset in x direction

      y_offsetfloat, optional

        Pixel offset in y direction

  add_shapefile_shape(image, area_def, filename, shape_id, feature_type=None, fill=None, fill_opacity=255, outline='white', width=1, outline_opacity=255, x_offset=0, y_offset=0)

    Add a single shape file shape from an ESRI shapefile.

    Note: To add all shapes in file use the ‘add_shape_file_shapes’ routine

    Note: Currently only supports lon-lat formatted coordinates.

    Parameters:
      imageobject

        PIL image object

      area_deflist [proj4_string, area_extent]
        proj4_string : str
        Projection of area as Proj.4 string
        area_extent : list
        Area extent as a list (LL_x, LL_y, UR_x, UR_y)
      filenamestr

        Path to ESRI shape file

      shape_idint

        integer id of shape in shape file {0; … }

      feature_type‘polygon’ or ‘line’,

        only to override the shape type defined in shapefile, optional

      fillstr or (R, G, B), optional

        Polygon fill color

      fill_opacityint, optional {0; 255}

        Opacity of polygon fill

      outlinestr or (R, G, B), optional

        line color

      widthfloat, optional

        line width

      outline_opacityint, optional {0; 255}

        Opacity of lines

      x_offsetfloat, optional

        Pixel offset in x direction

      y_offsetfloat, optional

        Pixel offset in y direction

  add_shapefile_shapes(image, area_def, filename, feature_type=None, fill=None, fill_opacity=255, outline='white', width=1, outline_opacity=255, x_offset=0, y_offset=0)

    Add shape file shapes from an ESRI shapefile.

    Note: Currently only supports lon-lat formatted coordinates.

    Parameters:
      imageobject

        PIL image object

      area_deflist [proj4_string, area_extent]
        proj4_string : str
        Projection of area as Proj.4 string
        area_extent : list
        Area extent as a list (LL_x, LL_y, UR_x, UR_y)
      filenamestr

        Path to ESRI shape file

      feature_type‘polygon’ or ‘line’,

        only to override the shape type defined in shapefile, optional

      fillstr or (R, G, B), optional

        Polygon fill color

      fill_opacityint, optional {0; 255}

        Opacity of polygon fill

      outlinestr or (R, G, B), optional

        line color

      widthfloat, optional

        line width

      outline_opacityint, optional {0; 255}

        Opacity of lines

      x_offsetfloat, optional

        Pixel offset in x direction

      y_offsetfloat, optional

        Pixel offset in y direction