Package mapnik :: Module _mapnik :: Class Map

Class Map

 object --+    
          |    
??.instance --+
              |
             Map

The map object.

Instance Methods
 
__init__(...)
__init__( (object)arg1, (int)width, (int)height [, (str)srs]) -> None : Create a Map with a width and height as integers and, optionally, an srs string either with a Proj.4 epsg code ('+init=epsg:<code>') or with a Proj.4 literal ('+proj=<literal>').
 
__reduce__(...)
helper for pickle
 
append_fontset(...)
append_fontset( (Map)arg1, (str)arg2, (FontSet)fontset) -> bool : Add a FontSet to the map.
 
append_style(...)
append_style( (Map)arg1, (str)style_name, (Style)style_object) -> bool : Insert a Mapnik Style onto the map by appending it.
 
buffered_envelope(...)
buffered_envelope( (Map)arg1) -> Box2d : Get the Box2d() of the Map given the Map.buffer_size.
 
envelope(...)
envelope( (Map)arg1) -> Box2d : Return the Map Box2d object and print the string representation of the current extent of the map.
 
find_fontset(...)
find_fontset( (Map)arg1, (str)name) -> FontSet : Find a fontset by name.
 
find_style(...)
find_style( (Map)arg1, (str)name) -> Style : Query the Map for a style by name and return a style object if found or raise KeyError style if not found.
 
pan(...)
pan( (Map)arg1, (int)x, (int)y) -> None : Set the Map center at a given x,y location as integers in the coordinates of the pixmap or map surface.
 
pan_and_zoom(...)
pan_and_zoom( (Map)arg1, (int)x, (int)y, (float)factor) -> None : Set the Map center at a given x,y location and zoom factor as a float.
 
query_map_point(...)
query_map_point( (Map)arg1, (int)layer_idx, (float)pixel_x, (float)pixel_y) -> Featureset : Query a Map Layer (by layer index) for features intersecting the given x,y location in the pixel coordinates of the rendered map image.
 
query_point(...)
query_point( (Map)arg1, (int)layer idx, (float)x, (float)y) -> Featureset : Query a Map Layer (by layer index) for features intersecting the given x,y location in the coordinates of map projection.
 
remove_all(...)
remove_all( (Map)arg1) -> None : Remove all Mapnik Styles and layers from the Map.
 
remove_style(...)
remove_style( (Map)arg1, (str)style_name) -> None : Remove a Mapnik Style from the map.
 
resize(...)
resize( (Map)arg1, (int)width, (int)height) -> None : Resize a Mapnik Map.
 
scale(...)
scale( (Map)arg1) -> float : Return the Map Scale.
 
scale_denominator(...)
scale_denominator( (Map)arg1) -> float : Return the Map Scale Denominator.
 
view_transform(...)
view_transform( (Map)arg1) -> ViewTransform : Return the map ViewTransform object which is used internally to convert between geographic coordinates and screen coordinates.
 
zoom(...)
zoom( (Map)arg1, (float)factor) -> None : Zoom in or out by a given factor.
 
zoom_all(...)
zoom_all( (Map)arg1) -> None : Set the geographical extent of the map to the combined extents of all active layers.
 
zoom_to_box(...)
zoom_to_box( (Map)arg1, (Box2d)Boxd2) -> None : Set the geographical extent of the map by specifying a Mapnik Box2d.

Inherited from unreachable.instance: __new__

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables
  __instance_size__ = 320
Properties
  aspect_fix_mode
Get/Set aspect fix mode.
  background
The background color of the map (same as background_color property).
  background_color
The background color of the map.
  background_image
The optional background image of the map.
  base
The base path of the map where any files using relative paths will be interpreted as relative to.
  buffer_size
Get/Set the size of buffer around map in pixels.
  height
Get/Set the height of the map in pixels.
  layers
The list of map layers.
  maximum_extent
The maximum extent of the map.
  parameters
TODO
  srs
Spatial reference in Proj.4 format.
  width
Get/Set the width of the map in pixels.

Inherited from object: __class__

Method Details

__init__(...)
(Constructor)

 

__init__( (object)arg1, (int)width, (int)height [, (str)srs]) -> None :
    Create a Map with a width and height as integers and, optionally,
    an srs string either with a Proj.4 epsg code ('+init=epsg:<code>')
    or with a Proj.4 literal ('+proj=<literal>').
    If no srs is specified the map will default to '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
    
    Usage:
    >>> from mapnik import Map
    >>> m = Map(600,400)
    >>> m
    <mapnik._mapnik.Map object at 0x6a240>
    >>> m.srs
    '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
    

    C++ signature :
        void __init__(_object*,int,int [,std::string])

Overrides: object.__init__

__reduce__(...)

 

helper for pickle

Overrides: object.__reduce__
(inherited documentation)

append_fontset(...)

 

append_fontset( (Map)arg1, (str)arg2, (FontSet)fontset) -> bool :
    Add a FontSet to the map.

    C++ signature :
        bool append_fontset(mapnik::Map {lvalue},std::string,mapnik::font_set)

append_style(...)

 

append_style( (Map)arg1, (str)style_name, (Style)style_object) -> bool :
    Insert a Mapnik Style onto the map by appending it.
    
    Usage:
    >>> sty
    <mapnik._mapnik.Style object at 0x6a330>
    >>> m.append_style('Style Name', sty)
    True # style object added to map by name
    >>> m.append_style('Style Name', sty)
    False # you can only append styles with unique names
    

    C++ signature :
        bool append_style(mapnik::Map {lvalue},std::string,mapnik::feature_type_style)

buffered_envelope(...)

 

buffered_envelope( (Map)arg1) -> Box2d :
    Get the Box2d() of the Map given
    the Map.buffer_size.
    
    Usage:
    >>> m = Map(600,400)
    >>> m.envelope()
    Box2d(-1.0,-1.0,0.0,0.0)
    >>> m.buffered_envelope()
    Box2d(-1.0,-1.0,0.0,0.0)
    >>> m.buffer_size = 1
    >>> m.buffered_envelope()
    Box2d(-1.02222222222,-1.02222222222,0.0222222222222,0.0222222222222)
    

    C++ signature :
        mapnik::box2d<double> buffered_envelope(mapnik::Map {lvalue})

envelope(...)

 

envelope( (Map)arg1) -> Box2d :
    Return the Map Box2d object
    and print the string representation
    of the current extent of the map.
    
    Usage:
    >>> m.envelope()
    Box2d(-0.185833333333,-0.96,0.189166666667,-0.71)
    >>> dir(m.envelope())
    ...'center', 'contains', 'expand_to_include', 'forward',
    ...'height', 'intersect', 'intersects', 'inverse', 'maxx',
    ...'maxy', 'minx', 'miny', 'width'
    

    C++ signature :
        mapnik::box2d<double> envelope(mapnik::Map {lvalue})

find_fontset(...)

 

find_fontset( (Map)arg1, (str)name) -> FontSet :
    Find a fontset by name.

    C++ signature :
        mapnik::font_set find_fontset(mapnik::Map,std::string)

find_style(...)

 

find_style( (Map)arg1, (str)name) -> Style :
    Query the Map for a style by name and return
    a style object if found or raise KeyError
    style if not found.
    
    Usage:
    >>> m.find_style('Style Name')
    <mapnik._mapnik.Style object at 0x654f0>
    

    C++ signature :
        mapnik::feature_type_style find_style(mapnik::Map,std::string)

pan(...)

 

pan( (Map)arg1, (int)x, (int)y) -> None :
    Set the Map center at a given x,y location
    as integers in the coordinates of the pixmap or map surface.
    
    Usage:
    >>> m = Map(600,400)
    >>> m.envelope().center()
    Coord(-0.5,-0.5) # default Map center
    >>> m.pan(-1,-1)
    >>> m.envelope().center()
    Coord(0.00166666666667,-0.835)
    

    C++ signature :
        void pan(mapnik::Map {lvalue},int,int)

pan_and_zoom(...)

 

pan_and_zoom( (Map)arg1, (int)x, (int)y, (float)factor) -> None :
    Set the Map center at a given x,y location
    and zoom factor as a float.
    
    Usage:
    >>> m = Map(600,400)
    >>> m.envelope().center()
    Coord(-0.5,-0.5) # default Map center
    >>> m.scale()
    -0.0016666666666666668
    >>> m.pan_and_zoom(-1,-1,0.25)
    >>> m.scale()
    0.00062500000000000001
    

    C++ signature :
        void pan_and_zoom(mapnik::Map {lvalue},int,int,double)

query_map_point(...)

 

query_map_point( (Map)arg1, (int)layer_idx, (float)pixel_x, (float)pixel_y) -> Featureset :
    Query a Map Layer (by layer index) for features 
    intersecting the given x,y location in the pixel
    coordinates of the rendered map image.
    Layer index starts at 0 (first layer in map).
    Will return a Mapnik Featureset if successful
    otherwise will return None.
    
    Usage:
    >>> featureset = m.query_map_point(0,200,200)
    >>> featureset
    <mapnik._mapnik.Featureset object at 0x23b0b0>
    >>> featureset.features
    >>> [<mapnik.Feature object at 0x3995630>]
    

    C++ signature :
        boost::shared_ptr<mapnik::Featureset> query_map_point(mapnik::Map,int,double,double)

query_point(...)

 

query_point( (Map)arg1, (int)layer idx, (float)x, (float)y) -> Featureset :
    Query a Map Layer (by layer index) for features 
    intersecting the given x,y location in the coordinates
    of map projection.
    Layer index starts at 0 (first layer in map).
    Will return a Mapnik Featureset if successful
    otherwise will return None.
    
    Usage:
    >>> featureset = m.query_point(0,-122,48)
    >>> featureset
    <mapnik._mapnik.Featureset object at 0x23b0b0>
    >>> featureset.features
    >>> [<mapnik.Feature object at 0x3995630>]
    

    C++ signature :
        boost::shared_ptr<mapnik::Featureset> query_point(mapnik::Map,int,double,double)

remove_all(...)

 

remove_all( (Map)arg1) -> None :
    Remove all Mapnik Styles and layers from the Map.
    
    Usage:
    >>> m.remove_all()
    

    C++ signature :
        void remove_all(mapnik::Map {lvalue})

remove_style(...)

 

remove_style( (Map)arg1, (str)style_name) -> None :
    Remove a Mapnik Style from the map.
    
    Usage:
    >>> m.remove_style('Style Name')
    

    C++ signature :
        void remove_style(mapnik::Map {lvalue},std::string)

resize(...)

 

resize( (Map)arg1, (int)width, (int)height) -> None :
    Resize a Mapnik Map.
    
    Usage:
    >>> m.resize(64,64)
    

    C++ signature :
        void resize(mapnik::Map {lvalue},unsigned int,unsigned int)

scale(...)

 

scale( (Map)arg1) -> float :
    Return the Map Scale.
    Usage:
    
    >>> m.scale()
    

    C++ signature :
        double scale(mapnik::Map {lvalue})

scale_denominator(...)

 

scale_denominator( (Map)arg1) -> float :
    Return the Map Scale Denominator.
    Usage:
    
    >>> m.scale_denominator()
    

    C++ signature :
        double scale_denominator(mapnik::Map {lvalue})

view_transform(...)

 

view_transform( (Map)arg1) -> ViewTransform :
    Return the map ViewTransform object
    which is used internally to convert between
    geographic coordinates and screen coordinates.
    
    Usage:
    >>> m.view_transform()
    

    C++ signature :
        mapnik::CoordTransform view_transform(mapnik::Map {lvalue})

zoom(...)

 

zoom( (Map)arg1, (float)factor) -> None :
    Zoom in or out by a given factor.
    Positive number zooms in, negative number
    zooms out.
    
    Usage:
    
    >>> m.zoom(0.25)
    

    C++ signature :
        void zoom(mapnik::Map {lvalue},double)

zoom_all(...)

 

zoom_all( (Map)arg1) -> None :
    Set the geographical extent of the map
    to the combined extents of all active layers.
    
    Usage:
    >>> m.zoom_all()
    

    C++ signature :
        void zoom_all(mapnik::Map {lvalue})

zoom_to_box(...)

 

zoom_to_box( (Map)arg1, (Box2d)Boxd2) -> None :
    Set the geographical extent of the map
    by specifying a Mapnik Box2d.
    
    Usage:
    >>> extext = Box2d(-180.0, -90.0, 180.0, 90.0)
    >>> m.zoom_to_box(extent)
    

    C++ signature :
        void zoom_to_box(mapnik::Map {lvalue},mapnik::box2d<double>)


Property Details

aspect_fix_mode

Get/Set aspect fix mode. Usage:

>>> m.aspect_fix_mode = aspect_fix_mode.GROW_BBOX
Get Method:
unreachable(...)
Set Method:
unreachable(...)

background

The background color of the map (same as background_color property).

Usage: >>> m.background = Color('steelblue')

Get Method:
unreachable(...)
Set Method:
unreachable(...)

background_color

The background color of the map.

Usage: >>> m.background_color = Color('steelblue')

Get Method:
unreachable(...)
Set Method:
unreachable(...)

background_image

The optional background image of the map.

Usage: >>> m.background_image = '/path/to/image.png'

Get Method:
unreachable(...)
Set Method:
unreachable(...)

base

The base path of the map where any files using relative paths will be interpreted as relative to.

Usage: >>> m.base_path = '.'

Get Method:
unreachable(...)
Set Method:
unreachable(...)

buffer_size

Get/Set the size of buffer around map in pixels.

Usage: >>> m.buffer_size 0 # zero by default >>> m.buffer_size = 2 >>> m.buffer_size 2

Get Method:
unreachable(...)
Set Method:
unreachable(...)

height

Get/Set the height of the map in pixels. Minimum settable size is 16 pixels.

Usage: >>> m.height 400 >>> m.height = 600 >>> m.height 600

Get Method:
unreachable(...)
Set Method:
unreachable(...)

layers

The list of map layers.

Usage: >>> m.layers <mapnik._mapnik.layers object at 0x6d458>>>> m.layers[0] <mapnik._mapnik.layer object at 0x5fe130>

Get Method:
unreachable(...)

maximum_extent

The maximum extent of the map.

Usage: >>> m.maximum_extent = Box2d(-180,-90,180,90)

Get Method:
unreachable(...)
Set Method:
unreachable(...)

parameters

TODO

Get Method:
unreachable(...)

srs

Spatial reference in Proj.4 format.
Either an epsg code or proj literal.
For example, a proj literal:
        '+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs'
and a proj epsg code:
        '+init=epsg:4326'

Note: using epsg codes requires the installation of
the Proj.4 'epsg' data file normally found in '/usr/local/share/proj'

Usage:
>>> m.srs
'+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs' # The default srs if not initialized with custom srs
>>> # set to google mercator with Proj.4 literal
... 
>>> m.srs = '+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs +over'

Get Method:
unreachable(...)
Set Method:
unreachable(...)

width

Get/Set the width of the map in pixels. Minimum settable size is 16 pixels.

Usage: >>> m.width 600 >>> m.width = 800 >>> m.width 800

Get Method:
unreachable(...)
Set Method:
unreachable(...)