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', **kwargs)[source]#
- Parameters
title (str) – Text of title.
font_size (str) – CSS font size that includes units.
kwargs – Additional style kwargs. Underscores in keys will be replaced with dashes
- 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#