ecoscope.mapping ================ .. py:module:: ecoscope.mapping Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/ecoscope/mapping/map/index Package Contents ---------------- .. py:class:: EcoMap(static=False, default_widgets=True, *args, **kwargs) Bases: :py:obj:`EcoMapMixin`, :py:obj:`lonboard.Map` The top-level class used to display a map in a Jupyter Widget. **Example:** ```py import geopandas as gpd from lonboard import Map, ScatterplotLayer, SolidPolygonLayer # A GeoDataFrame with Point geometries point_gdf = gpd.GeoDataFrame() point_layer = ScatterplotLayer.from_geopandas( point_gdf, get_fill_color=[255, 0, 0], ) # A GeoDataFrame with Polygon geometries polygon_gdf = gpd.GeoDataFrame() polygon_layer = SolidPolygonLayer.from_geopandas( gdf, get_fill_color=[255, 0, 0], ) m = Map([point_layer, polygon_layer]) ``` .. py:method:: add_layer(layer, zoom = False) Adds a layer or list of layers to the map :param layer: :type layer: lonboard.BaseLayer or list[lonboard.BaseLayer] :param zoom: Whether to zoom the map to the new layer :type zoom: bool .. py:method:: add_widget(widget) Adds a deck widget to the map :param widget: :type widget: lonboard.BaseDeckWidget or list[lonboard.BaseDeckWidget] .. py:method:: layers_from_gdf(gdf, **kwargs) :staticmethod: Creates map layers from the provided gdf, returns multiple layers when geometry is mixed Style kwargs are provided to all created layers :param gdf: The data to be cleaned :type gdf: gpd.GeoDataFrame :param kwargs: :type kwargs: Additional kwargs passed to lonboard .. py:method:: _clean_gdf(gdf) :staticmethod: Cleans a gdf for use in a map layer, ensures EPSG:4326 and removes any empty geometry :param gdf: The data to be cleaned :type gdf: gpd.GeoDataFrame .. py:method:: polyline_layer(gdf, color_column = None, **kwargs) :staticmethod: Creates a polyline layer to add to a map :param gdf: The data used to create the visualization layer :type gdf: gpd.GeoDataFrame :param kwargs: Additional kwargs passed to lonboard.PathLayer: http://developmentseed.org/lonboard/latest/api/layers/path-layer/ .. py:method:: polygon_layer(gdf, fill_color_column = None, line_color_column = None, **kwargs) :staticmethod: Creates a polygon layer to add to a map :param gdf: The data used to create the visualization layer :type gdf: gpd.GeoDataFrame :param kwargs: Additional kwargs passed to lonboard.PathLayer: http://developmentseed.org/lonboard/latest/api/layers/polygon-layer/ .. py:method:: point_layer(gdf, fill_color_column = None, line_color_column = None, **kwargs) :staticmethod: Creates a polygon layer to add to a map :param gdf: The data used to create the visualization layer :type gdf: gpd.GeoDataFrame :param kwargs: Additional kwargs passed to lonboard.ScatterplotLayer: http://developmentseed.org/lonboard/latest/api/layers/scatterplot-layer/ .. py:method:: add_legend(labels, colors, **kwargs) Adds a legend to the map :param placement: One of "top-left", "top-right", "bottom-left", "bottom-right" or "fill" Where to place the widget within the map :type placement: str :param title: A title displayed on the widget :type title: str :param labels: A list or series of labels :type labels: list or pd.Series :param colors: A list or series of colors as string hex values or RGBA color tuples :type colors: list or pd.Series :param style: Additional style params :type style: dict .. py:method:: add_north_arrow(**kwargs) Adds a north arrow to the map :param placement: Where to place the widget within the map :type placement: str, one of "top-left", "top-right", "bottom-left", "bottom-right" or "fill" :param style: Additional style params :type style: dict .. py:method:: add_scale_bar(**kwargs) Adds a scale bar to the map :param placement: Where to place the widget within the map :type placement: str, one of "top-left", "top-right", "bottom-left", "bottom-right" or "fill" :param use_imperial: If true, show scale in miles/ft, rather than m/km :type use_imperial: bool :param style: Additional style params :type style: dict .. py:method:: add_title(title, **kwargs) Adds a title to the map :param title: The map title :type title: str :param style: Additional style params :type style: dict .. py:method:: add_save_image(**kwargs) Adds a button to save the map as a png :param placement: Where to place the widget within the map :type placement: str, one of "top-left", "top-right", "bottom-left", "bottom-right" or "fill" :param style: Additional style params :type style: dict .. py:method:: ee_layer(ee_object, visualization_params, **kwargs) :staticmethod: Creates a layer from the provided Earth Engine. If an EE.Image/EE.ImageCollection or EE.FeatureCollection is provided, this results in a BitmapTileLayer being added For EE.Geometry objects, a list of ScatterplotLayer,PathLayer and PolygonLayer will be added based on the geometry itself (see add_gdf) :param ee_object: The ee object to represent as a layer :type ee_object: ee.Image, ee.ImageCollection, ee.Geometry, ee.FeatureCollection] :param visualization_params: Visualization params passed to EarthEngine :type visualization_params: dict :param kwargs: Additional params passed to either lonboard.BitmapTileLayer or add_gdf .. py:method:: zoom_to_bounds(feat) Zooms the map to the bounds of a dataframe or layer. :param feat: The feature to zoom to :type feat: BaseLayer, List[lonboard.BaseLayer], gpd.GeoDataFrame .. py:method:: geotiff_layer(tiff, cmap = None, opacity = 0.7) :staticmethod: Creates a layer from a given geotiff Note that since deck.gl tiff support is limited, this extracts the CRS/Bounds from the tiff and converts the image data in-memory to PNG :param tiff: The string path to a tiff on disk or a rio.MemoryFile :type tiff: str | rio.MemoryFile :param cmap: The colormap to apply to the raster :type cmap: str or matplotlib.colors.Colormap :param opacity: The opacity of the overlay :type opacity: float .. py:method:: pil_layer(image, bounds, opacity=1) :staticmethod: Creates layer from a PIL.Image :param image: The image to be overlaid :type image: PIL.Image :param bounds: Tuple containing the EPSG:4326 (minx, miny, maxx, maxy) values bounding the given image :type bounds: tuple :param opacity: Sets opacity of overlaid image :type opacity: float, optional .. py:method:: get_named_tile_layer(layer) :staticmethod: .. py:method:: to_html(filename = None, title = None, maximize = True) Save the current map as a standalone HTML file. :param filename: where to save the generated HTML file. Other args: title: A title for the exported map. This will show as the browser tab name. :returns: If `filename` is not passed, returns the HTML content as a `str`.