ecoscope.mapping.map
#
Module Contents#
- class ecoscope.mapping.map.EcoMap(*args, static=False, print_control=True, **kwargs)[source]#
Bases:
EcoMapMixin
,ecoscope.contrib.foliumap.Map
The Map class inherits folium.Map. By default, the Map will add OpenStreetMap as the basemap.
- Returns:
folium map object.
- Return type:
object
- add_gdf(data, *args, simplify_tolerance=None, **kwargs)[source]#
Wrapper for geopandas.explore._explore.
- add_legend(*args, **kwargs)[source]#
Patched method for allowing legend hex colors to start with a “#”.
- add_north_arrow(position='topright', scale=1.0)[source]#
- Parameters:
position (str) – Possible values are ‘topleft’, ‘topright’, ‘bottomleft’ or ‘bottomright’.
scale (float) – Scale dimensions of north arrow.
- add_title(title, font_size='32px', font_style='normal', font_family='Helvetica', font_color='rgba(0,0,0,1)', position=None, background_color='#FFFFFF99', outline='0px solid rgba(0, 0, 0, 0)', **kwargs)[source]#
- Parameters:
title (str) – Text of title.
font_size (str) – CSS font size that includes units. font_style : str
font_family (str"Helvetica",) – Font family selection; Could be one or more separated by spaces.
font_color (str) – Text color (css color property); supports rgb, rgba and hex string formats.
position (dict|None) –
Dict object with top, left and bottom margin values for the title container position. ex. {
”top”: “10px”, “left”: “25px”, “right”: “0px”, “bottom”: “0px”
}
All keys are optional in the dictionary (could be passed some of them as necessary). Values could be passed as px or accepted css metric. Default None.
background_color (str) – Box background color; supports rgb, rgba and hex string formats. Default ‘#FFFFFF99’.
outline (str) –
Element outline values (width style color_with_transparency). Could be passed as a string with spaced separated values or a dict structure: ex. {
”width”: “1px”, “style”: “solid”, “color”: “#FFFFFF99” # or rgb/rgba tuple (0, 0, 0, 0)
}
kwargs – Additional style kwargs. Underscores in keys will be replaced with dashes
font_style (str) –
- to_png(outfile, sleep_time=10, **kwargs)[source]#
- Parameters:
outfile (str, Pathlike) – Output destination
sleep_time (int, optional) – Additional seconds to wait before taking screenshot. Should be increased if map tiles in the output haven’t fully loaded but can also be decreased in most cases.
- add_ee_layer(ee_object, visualization_params, name)[source]#
Method for displaying Earth Engine image tiles.
- Parameters:
ee_object –
visualization_params –
name –
- Return type:
None
- zoom_to_bounds(bounds)[source]#
Zooms to a bounding box in the form of [minx, miny, maxx, maxy].
- Parameters:
bounds ([x1, y1, x2, y2]) – Map extent in WGS 84
- zoom_to_gdf(gs)[source]#
- Parameters:
gs (gpd.GeoSeries or gpd.GeoDataFrame) – Geometry to adjust map bounds to. CRS will be converted to WGS 84.
- add_local_geotiff(path, zoom=False, cmap=None, colorbar=True)[source]#
Displays a local GeoTIFF.
- Parameters:
path (str, Pathlike) – Path to local GeoTIFF
zoom (bool) – Zoom to displayed GeoTIFF
cmap (matplotlib.colors.Colormap or str or None) – Matplotlib colormap to apply to raster
colorbar (bool) – Whether to add colorbar for provided cmap. Does nothing if cmap is not provided.
- class ecoscope.mapping.map.ControlElement(html, position='bottomright')[source]#
Bases:
branca.element.MacroElement
Class to wrap arbitrary HTML as Leaflet Control.
- Parameters:
html (str) – HTML to render an element from.
position (str) – Possible values are ‘topleft’, ‘topright’, ‘bottomleft’ or ‘bottomright’.
- _template#
- class ecoscope.mapping.map.FloatElement(html, left='', right='', top='', bottom='')[source]#
Bases:
branca.element.MacroElement
Class to wrap arbitrary HTML as a floating Element.
- Parameters:
html (str) – HTML to render an element from.
left (str) – Distance between edge of map and nearest edge of element. Two should be provided. Style can also be specified in html.
right (str) – Distance between edge of map and nearest edge of element. Two should be provided. Style can also be specified in html.
top (str) – Distance between edge of map and nearest edge of element. Two should be provided. Style can also be specified in html.
bottom (str) – Distance between edge of map and nearest edge of element. Two should be provided. Style can also be specified in html.
- _template#
- class ecoscope.mapping.map.GeoTIFFElement(url, zoom=False)[source]#
Bases:
branca.element.MacroElement
Class to display a GeoTIFF.
- Parameters:
url (str) – URL of GeoTIFF
zoom (bool) – Zoom to displayed GeoTIFF
- _template#
- class ecoscope.mapping.map.PrintControl[source]#
Bases:
branca.element.MacroElement
This is a parent class for Elements defined by a macro template. To compute your own element, all you have to do is:
To inherit from this class
Overwrite the ‘_name’ attribute
Overwrite the ‘_template’ attribute with something of the form:
{% macro header(this, kwargs) %} ... {% endmacro %} {% macro html(this, kwargs) %} ... {% endmacro %} {% macro script(this, kwargs) %} ... {% endmacro %}
- _template#