cartograph.map¶
- class cartograph.map.Map¶
Class for collecting all the elements of a map with methods for drawing map tiles.
- bound_by_box(bottom, top, left, right)¶
Set the bounds of the map, given as latitude and longitude bounds.
- bound_by_osm_tiles(zoom, *args)¶
Calculate the bounds corresponding to the minimal rectangle of tiles of zoom level zoom that includes one or more points, given by pairs of (lat,lon) coordinates.
- get_bounds(padding=0)¶
Returns the map bounds in projected coordinates with optional padding.
- get_latlon_bounds(padding=0)¶
Returns the map bounds in lat/lon coordinates with optional padding.
- number_of_tiles(zoom)¶
Returns the (minimal) number of tiles of zoom level zoom that cover the map.
- projection(lat, lon)¶
The projection from lat/lon coordinates to cartesian coordinates. By default, this is the Mercator projection. Override this method to change the projection.
- add_area(boundary, style, check_bounds=True)¶
Add an area feature to the map with (2,N) numpy array boundary and
AreaStyle
style. Each column of boundary is a lat/lon coordinate. Optionally check that at least one vertex of the boundary is within the bounds of the map (default True).See also
Area
- add_way(vertices, style, check_bounds=True)¶
Add a way feature to the map with (2,N) numpy array vertices and
WayStyle
style. Each column of vertices is a lat/lon coordinate. Optionally check that at least one vertex of the way is within the bounds of the map (default True).See also
Way
- add_name(label, location, style, check_bounds=True)¶
Add a name feature to the map with string label, (2,) numpy array location and
NameStyle
style. Optionally check that the location is within the bounds of the map (default True). Currently this check always returns True.See also
Name
- add_node(location, style, check_bounds=True)¶
Add a node feature to the map with (2,) numpy array location and
NodeStyle
style. Optionally check that the location is within the bounds of the map (default True). Currently this check always returns True.See also
Node
- add_elevation(data, style)¶
Add elevation data to the map with
ElevationStyle
style. The data is expected to be an (3,N) numpy array where each row gives a latitude (in degrees), longitude (in degrees) and elevation (can be in any units).See also
Elevation
- set_background_color(background_color)¶
Set the background colour of the map.
See also
Elevation.draw_background_image()
.
- create_figure(width, height)¶
Create a figure to draw the map onto.
- plot()¶
Plot the map features. This method does not create the figure,
create_figure()
must be called first.See also
draw_zoom_levels()
anddraw_image()
.
- draw_zoom_levels(min, max=None, directory='tiles', disp=False)¶
Draw all the tiles from zoom level min (inclusive) to max (not inclusve). If max is not given, draws the tiles for zoom level min only. The tiles are saved using slippy map tilenames within the parent directory directory. Optionally display progress (default False).
- draw_tile(x, y, zoom, directory='tiles')¶
Draw an individual map tile given by x, y and zoom (see slippy map tilenames). The tiles are saved using slippy map tilenames within the parent directory directory.
- draw_image(filename='map.png', height=1024)¶
Draw the map and save it as a single image with height in pixels (the width is calculated from the map bounds). The image format is determined from the filename.