示例#1
0
def get_base_map(location, zoom_start=5):
    """
    Get map with all the base defined layers
    :param location: (lat, lon)
    :param zoom_start: integer
    :return: map, marker_layer
    """

    my_map = folium.Map(location=location, zoom_start=zoom_start)

    # add possible tiles
    folium.TileLayer('cartodbpositron').add_to(my_map)
    folium.TileLayer('cartodbdark_matter').add_to(my_map)
    # folium.TileLayer('openstreetmap').add_to(my_map)
    folium.TileLayer('stamentoner').add_to(my_map)
    folium.WmsTileLayer(
        url=
        'https://server.arcgisonline.com/ArcGIS/rest/services/Canvas/World_Light_Gray_Base/MapServer/tile/{z}/{y}/{x}',
        layers='Esri_WorldGray',
        attr='Tiles © Esri — Esri, DeLorme, NAVTEQ').add_to(my_map)

    # add markers layer
    marker_cluster = MarkerCluster().add_to(my_map)

    # add the layer control
    folium.LayerControl().add_to(my_map)

    return my_map, marker_cluster
def make_map(bbox, **kw):
    line = kw.pop("line", True)
    layers = kw.pop("layers", True)
    zoom_start = kw.pop("zoom_start", 5)

    lon = (bbox[0] + bbox[2]) / 2
    lat = (bbox[1] + bbox[3]) / 2
    m = folium.Map(
        width="100%", height="100%", location=[lat, lon], zoom_start=zoom_start
    )

    if layers:
        url = "http://geoport-dev.whoi.edu/thredds/wms/coawst_4/use/fmrc/coawst_4_use_best.ncd"
        w = folium.WmsTileLayer(
            url,
            name="COAWST Wave Height",
            fmt="image/png",
            layers="Hwave",
            style="boxfill/rainbow",
            COLORSCALERANGE="0,5",
            overlay=True,
            transparent=True,
        )
        w.add_to(m)

    if line:
        p = folium.PolyLine(
            get_coordinates(bbox), color="#FF0000", weight=2, opacity=0.9
        )
        p.add_to(m)
    return m
示例#3
0
    def addToMap(self,img,vizParams,name):
         map_id = ee.Image(img.visualize(**vizParams)).getMapId()
         tile_url_template = "https://earthengine.googleapis.com/map/{mapid}/{{z}}/{{x}}/{{y}}?token={token}"
         mapurl = tile_url_template.format(**map_id)
         folium.WmsTileLayer(mapurl,name=name).add_to(self._map)

         return
def make_map(bbox, **kw):
    line = kw.pop("line", True)
    layers = kw.pop("layers", True)
    zoom_start = kw.pop("zoom_start", 5)

    lon = (bbox[0] + bbox[2]) / 2
    lat = (bbox[1] + bbox[3]) / 2
    m = folium.Map(
        width="100%", height="100%", location=[lat, lon], zoom_start=zoom_start
    )

    if layers:
        url = "http://oos.soest.hawaii.edu/thredds/wms/hioos/satellite/dhw_5km"
        w = folium.WmsTileLayer(
            url,
            name="Sea Surface Temperature",
            fmt="image/png",
            layers="CRW_SST",
            attr="PacIOOS TDS",
            overlay=True,
            transparent=True,
        )
        w.add_to(m)

    if line:
        p = folium.PolyLine(
            get_coordinates(bbox), color="#FF0000", weight=2, opacity=0.9,
        )
        p.add_to(m)
    return m
示例#5
0
def test_wms_service():
    m = Map([40, -100], zoom_start=4)
    url = 'http://mesonet.agron.iastate.edu/cgi-bin/wms/nexrad/n0r.cgi'
    w = folium.WmsTileLayer(url,
                            name='test',
                            fmt='image/png',
                            layers='nexrad-n0r-900913',
                            attr=u'Weather data © 2012 IEM Nexrad',
                            transparent=True)
    w.add_to(m)
    m._repr_html_()

    bounds = m.get_bounds()
    assert bounds == [[None, None], [None, None]], bounds
示例#6
0
文件: eefolium.py 项目: xyt556/geemap
        attr='Esri',
        name='Esri Physical Map',
        overlay=True,
        control=True),
    'Bing VirtualEarth':
    folium.TileLayer(
        tiles='http://ecn.t3.tiles.virtualearth.net/tiles/a{q}.jpeg?g=1',
        attr='Microsoft',
        name='Bing VirtualEarth',
        overlay=True,
        control=True),
    '3DEP Elevation':
    folium.WmsTileLayer(
        url=
        'https://elevation.nationalmap.gov/arcgis/services/3DEPElevation/ImageServer/WMSServer?',
        layers='3DEPElevation:None',
        attr='USGS',
        name='3DEP Elevation',
        overlay=True,
        control=True),
    'NAIP Imagery':
    folium.WmsTileLayer(
        url=
        'https://services.nationalmap.gov/arcgis/services/USGSNAIPImagery/ImageServer/WMSServer?',
        layers='0',
        attr='USGS',
        name='NAIP Imagery',
        overlay=True,
        control=True),
}

示例#7
0
def make_map(bbox, **kw):
    """
    Creates a folium map instance for SECOORA.

    Examples
    --------
    >>> from folium import Map
    >>> bbox = [-87.40, 24.25, -74.70, 36.70]
    >>> m = make_map(bbox)
    >>> isinstance(m, Map)
    True

    """
    import folium

    line = kw.pop('line', True)
    layers = kw.pop('layers', True)
    hf_radar = kw.pop('hf_radar', True)
    zoom_start = kw.pop('zoom_start', 5)

    lon, lat = np.array(bbox).reshape(2, 2).mean(axis=0)
    m = folium.Map(width='100%',
                   height='100%',
                   location=[lat, lon],
                   zoom_start=zoom_start)

    if hf_radar:
        url = 'http://hfrnet.ucsd.edu/thredds/wms/HFRNet/USEGC/6km/hourly/RTV'
        w = folium.WmsTileLayer(url,
                                name='HF Radar',
                                fmt='image/png',
                                layers='surface_sea_water_velocity',
                                attr='HFRNet',
                                overlay=True,
                                transparent=True)
        w.add_to(m)
    if layers:
        add = 'MapServer/tile/{z}/{y}/{x}'
        base = 'http://services.arcgisonline.com/arcgis/rest/services'
        ESRI = {
            'Imagery': 'World_Imagery/MapServer',
            'Ocean_Base': 'Ocean/World_Ocean_Base',
            'Topo_Map': 'World_Topo_Map/MapServer',
            'Street_Map': 'World_Street_Map/MapServer',
            'Physical_Map': 'World_Physical_Map/MapServer',
            'Terrain_Base': 'World_Terrain_Base/MapServer',
            'NatGeo_World_Map': 'NatGeo_World_Map/MapServer',
            'Shaded_Relief': 'World_Shaded_Relief/MapServer',
            'Ocean_Reference': 'Ocean/World_Ocean_Reference',
            'Navigation_Charts': 'Specialty/World_Navigation_Charts'
        }
        for name, url in ESRI.items():
            url = '{}/{}/{}'.format(base, url, add)

            w = folium.TileLayer(tiles=url,
                                 name=name,
                                 attr='ESRI',
                                 overlay=True)
            w.add_to(m)

    if line:  # Create the map and add the bounding box line.
        p = folium.PolyLine(get_coordinates(bbox),
                            color='#FF0000',
                            weight=2,
                            opacity=0.9,
                            latlon=True)
        p.add_to(m)

    folium.LayerControl().add_to(m)
    return m
示例#8
0
def setOptions(self, mapTypeId='HYBRID', styles={}, types=[]):
    # Add custom basemaps to folium
    basemaps = {
        'ROADMAP':
        folium.TileLayer(
            tiles='https://mt1.google.com/vt/lyrs=m&x={x}&y={y}&z={z}',
            attr='Google',
            name='Google Maps',
            overlay=True,
            control=True),
        'SATELLITE':
        folium.TileLayer(
            tiles='https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}',
            attr='Google',
            name='Google Satellite',
            overlay=True,
            control=True),
        'TERRAIN':
        folium.TileLayer(
            tiles='https://mt1.google.com/vt/lyrs=p&x={x}&y={y}&z={z}',
            attr='Google',
            name='Google Terrain',
            overlay=True,
            control=True),
        'HYBRID':
        folium.TileLayer(
            tiles='https://mt1.google.com/vt/lyrs=y&x={x}&y={y}&z={z}',
            attr='Google',
            name='Google Satellite',
            overlay=True,
            control=True),
        'ESRI':
        folium.TileLayer(
            tiles=
            'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
            attr='Esri',
            name='Esri Satellite',
            overlay=True,
            control=True),
        'Esri Ocean':
        folium.TileLayer(
            tiles=
            'https://services.arcgisonline.com/ArcGIS/rest/services/Ocean/World_Ocean_Base/MapServer/tile/{z}/{y}/{x}',
            attr='Esri',
            name='Esri Ocean',
            overlay=True,
            control=True),
        'Esri Satellite':
        folium.TileLayer(
            tiles=
            'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
            attr='Esri',
            name='Esri Satellite',
            overlay=True,
            control=True),
        'Esri Standard':
        folium.TileLayer(
            tiles=
            'https://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer/tile/{z}/{y}/{x}',
            attr='Esri',
            name='Esri Standard',
            overlay=True,
            control=True),
        'Esri Terrain':
        folium.TileLayer(
            tiles=
            'https://server.arcgisonline.com/ArcGIS/rest/services/World_Terrain_Base/MapServer/tile/{z}/{y}/{x}',
            attr='Esri',
            name='Esri Terrain',
            overlay=True,
            control=True),
        'Esri Transportation':
        folium.TileLayer(
            tiles=
            'https://server.arcgisonline.com/ArcGIS/rest/services/Reference/World_Transportation/MapServer/tile/{z}/{y}/{x}',
            attr='Esri',
            name='Esri Transportation',
            overlay=True,
            control=True),
        'Esri Topo World':
        folium.TileLayer(
            tiles=
            'https://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}',
            attr='Esri',
            name='Esri Topo World',
            overlay=True,
            control=True),
        'Esri National Geographic':
        folium.TileLayer(
            tiles=
            'http://services.arcgisonline.com/ArcGIS/rest/services/NatGeo_World_Map/MapServer/tile/{z}/{y}/{x}',
            attr='Esri',
            name='Esri National Geographic',
            overlay=True,
            control=True),
        'Esri Shaded Relief':
        folium.TileLayer(
            tiles=
            'https://services.arcgisonline.com/arcgis/rest/services/World_Shaded_Relief/MapServer/tile/{z}/{y}/{x}',
            attr='Esri',
            name='Esri Shaded Relief',
            overlay=True,
            control=True),
        'Esri Physical Map':
        folium.TileLayer(
            tiles=
            'https://services.arcgisonline.com/arcgis/rest/services/World_Physical_Map/MapServer/tile/{z}/{y}/{x}',
            attr='Esri',
            name='Esri Physical Map',
            overlay=True,
            control=True),
        'Bing VirtualEarth':
        folium.TileLayer(
            tiles='http://ecn.t3.tiles.virtualearth.net/tiles/a{q}.jpeg?g=1',
            attr='Microsoft',
            name='Bing VirtualEarth',
            overlay=True,
            control=True),
        '3DEP Elevation':
        folium.WmsTileLayer(
            url=
            'https://elevation.nationalmap.gov/arcgis/services/3DEPElevation/ImageServer/WMSServer?',
            layers='3DEPElevation:None',
            attr='USGS',
            name='3DEP Elevation',
            overlay=True,
            control=True),
        'NAIP Imagery':
        folium.WmsTileLayer(
            url=
            'https://services.nationalmap.gov/arcgis/services/USGSNAIPImagery/ImageServer/WMSServer?',
            layers='0',
            attr='USGS',
            name='NAIP Imagery',
            overlay=True,
            control=True),
    }

    try:
        basemaps[mapTypeId].add_to(self)
    except:
        print(
            'Basemap can only be one of "ROADMAP", "SATELLITE", "HYBRID", "TERRAIN", "NAIP", or "ESRI"'
        )
示例#9
0
import folium

zoom_start = 7
lon = (bbox[0] + bbox[1]) / 2
lat = (bbox[2] + bbox[3]) / 2
m = folium.Map(width='100%',
               height='100%',
               location=[lat, lon],
               zoom_start=zoom_start)

url = 'https://gis.ngdc.noaa.gov/arcgis/services/gebco08_hillshade/MapServer/WMSServer'
w = folium.WmsTileLayer(url,
                        name='GEBCO Bathymetry',
                        fmt='image/png',
                        layers='GEBCO_08 Hillshade',
                        attr='GEBCO',
                        overlay=True,
                        transparent=True)

w.add_to(m)

colors = ['orange', 'pink', 'yellow']

k = 0
for glider, df in dfs.items():

    line = folium.PolyLine(locations=list(zip(df['latitude'],
                                              df['longitude'])),
                           color=colors[k],
                           weight=8,
示例#10
0
def plot_map(holes, render_holes=True, popup_size=(3, 3)):
    """Plot a leaflet map from holes with popup hole plots.

    Parameters
    ----------
    holes : holes object
    render_holes : bool
        Render popup diagrams for holes
    popup_size : tuple
        size in inches of popup figure

    Returns
    -------
    map_fig : folium map object
    """
    holes_filtered = []
    first_system = False
    if len(holes) == 0:
        raise ValueError("Can't plot empty holes -object.")
    for hole in holes:
        if hasattr(hole, "header") and hasattr(hole.header, "XY"):
            if "X" in hole.header.XY and "Y" in hole.header.XY:
                holes_filtered.append(hole)
                coord_system = hole.fileheader.KJ["Coordinate system"]
                coord_system = coord_string_fix(coord_system)
                if re.search(r"^EPSG:\d+$", coord_system, re.IGNORECASE):
                    input_epsg = coord_system
                elif coord_system in EPSG_SYSTEMS:
                    input_epsg = EPSG_SYSTEMS[coord_system]
                else:
                    msg = "Coordinate system {} is not implemented"
                    msg = msg.format(coord_system)
                    raise NotImplementedError(msg)
                if not first_system:
                    first_system = coord_system
                else:
                    if not first_system == coord_system:
                        raise ValueError(
                            "Coordinate system is not uniform in holes -object"
                        )
    holes_filtered = Holes(holes_filtered)

    x_all, y_all = [], []
    for i in holes_filtered:
        x_all.append(i.header["XY"]["X"])
        y_all.append(i.header["XY"]["Y"])

    x, y = np.mean(x_all), np.mean(y_all)
    x, y = project_points(x, y, input_epsg)
    max_zoom = 22
    map_fig = folium.Map(
        location=[x, y],
        zoom_start=14,
        max_zoom=22,
        prefer_canvas=True,
        control_scale=True,
        tiles=None,
    )
    folium.TileLayer("OpenStreetMap", maxNativeZoom=19,
                     maxZoom=max_zoom).add_to(map_fig)
    folium.TileLayer("Stamen Terrain", maxNativeZoom=18,
                     maxZoom=max_zoom).add_to(map_fig)
    folium.TileLayer("CartoDB positron", maxNativeZoom=18,
                     maxZoom=max_zoom).add_to(map_fig)
    esri_url = ("https://server.arcgisonline.com/ArcGIS/rest/services/" +
                "World_Imagery/MapServer/tile/{z}/{y}/{x}")
    folium.TileLayer(
        tiles=esri_url,
        attr="Esri",
        name="Esri Satellite",
        overlay=False,
        control=True,
        maxNativeZoom=18,
        maxZoom=max_zoom,
    ).add_to(map_fig)
    mml_url_perus = "http://tiles.kartat.kapsi.fi/peruskartta/{z}/{x}/{y}.jpg"
    mml_url_orto = "http://tiles.kartat.kapsi.fi/ortokuva/{z}/{x}/{y}.jpg"
    folium.TileLayer(
        tiles=mml_url_perus,
        attr="MML",
        name="MML peruskartta",
        overlay=False,
        control=True,
        maxNativeZoom=18,
        maxZoom=max_zoom,
    ).add_to(map_fig)
    folium.TileLayer(
        tiles=mml_url_orto,
        attr="MML",
        name="MML ilmakuva",
        overlay=False,
        control=True,
        maxNativeZoom=18,
        maxZoom=max_zoom,
    ).add_to(map_fig)

    gtk_url = (
        "http://gtkdata.gtk.fi/arcgis/services/Rajapinnat/GTK_Maapera_WMS/MapServer/WMSServer?"
    )
    folium.WmsTileLayer(
        name="GTK Maaperäkartta",
        url=gtk_url,
        fmt="image/png",
        layers=["maapera_100k_kerrostumat_ja_muodostumat"
                ],  # "maapera_200k_maalajit"
        show=False,
        transparent=True,
        opacity=0.5,
    ).add_to(map_fig)

    folium.WmsTileLayer(
        name="GTK Sulfaattimaat",
        url=gtk_url,
        fmt="image/png",
        layers=["happamat_sulfaattimaat_250k_alueet"],
        show=False,
        transparent=True,
        opacity=0.5,
    ).add_to(map_fig)

    sw_bounds = project_points(min(x_all), min(y_all), input_epsg)
    ne_bounds = project_points(max(x_all), max(y_all), input_epsg)

    map_fig.fit_bounds([sw_bounds, ne_bounds])

    cluster = MarkerCluster(
        control=False,
        options=dict(animate=True,
                     maxClusterRadius=15,
                     showCoverageOnHover=False,
                     disableClusteringAtZoom=20),
    ).add_to(map_fig)
    map_fig.add_child(cluster)
    hole_clusters = {}
    colors = [
        "red",
        "blue",
        "green",
        "purple",
        "orange",
        "darkred",
        "lightred",
        "darkblue",
        "darkgreen",
        "cadetblue",
        "darkpurple",
        "pink",
        "lightblue",
        "lightgreen",
    ]
    colors = cycle(colors)
    clust_icon_kwargs = {}
    for color, key in zip(colors, holes_filtered.value_counts().keys()):
        hole_clusters[key] = folium.plugins.FeatureGroupSubGroup(
            cluster, name=ABBREVIATIONS[key], show=True)
        clust_icon_kwargs[key] = dict(color=color, icon="")
        map_fig.add_child(hole_clusters[key])

    for i, hole in enumerate(holes_filtered):
        x, y = [hole.header.XY["X"], hole.header.XY["Y"]]
        x, y = project_points(x, y, input_epsg)

        if hasattr(hole.header,
                   "TT") and "Survey abbreviation" in hole.header["TT"]:
            key = hole.header["TT"]["Survey abbreviation"]
        else:
            key = "Missing survey abbreviation"
        if render_holes and key != "Missing survey abbreviation":
            try:
                hole_svg = plot_hole(hole, output="svg", figsize=popup_size)
                popup = folium.Popup(hole_svg)
                icon = get_icon(key, clust_icon_kwargs)
                folium.Marker(location=[x, y], popup=popup,
                              icon=icon).add_to(hole_clusters[key])

            except (NotImplementedError, KeyError, TypeError):
                icon = get_icon(key, clust_icon_kwargs)
                folium.Marker(
                    location=[x, y],
                    popup=ABBREVIATIONS[key] + " " + str(i),
                    icon=icon,
                ).add_to(hole_clusters[key])
        else:
            icon = get_icon(key, clust_icon_kwargs)
            folium.Marker(
                location=[x, y],
                popup=ABBREVIATIONS[key] + " " + str(i),
                icon=icon,
            ).add_to(hole_clusters[key])

    folium.LayerControl().add_to(map_fig)
    MeasureControl(
        secondary_length_unit="",
        secondary_area_unit="",
        activeColor="#aecfeb",
        completedColor="#73b9f5",
    ).add_to(map_fig)
    fmtr = "function(num) {return L.Util.formatNum(num, 7) + ' º ';};"
    MousePosition(
        position="topright",
        separator=" | ",
        prefix="WGS84 ",
        lat_formatter=fmtr,
        lng_formatter=fmtr,
    ).add_to(map_fig)
    return map_fig
示例#11
0
m = folium.Map(location=[lat, lon], tiles="OpenStreetMap", zoom_start=4)

Fullscreen(position="topright", force_separate_button=True).add_to(m)

marker_cluster0 = MarkerCluster(name="Observations")
marker_cluster1 = MarkerCluster(name="Past predictions")
marker_cluster0.add_to(m)
marker_cluster1.add_to(m)


url = "http://oos.soest.hawaii.edu/thredds/wms/hioos/satellite/dhw_5km"
w0 = folium.WmsTileLayer(
    url,
    name="Sea Surface Temperature",
    fmt="image/png",
    layers="CRW_SST",
    attr="PacIOOS TDS",
    overlay=True,
    transparent=True,
)

w0.add_to(m)

url = "http://hfrnet.ucsd.edu/thredds/wms/HFRNet/USEGC/6km/hourly/RTV"
w1 = folium.WmsTileLayer(
    url,
    name="HF Radar",
    fmt="image/png",
    layers="surface_sea_water_velocity",
    attr="HFRNet",
    overlay=True,
示例#12
0
def xyz_to_folium():
    """Convert xyz tile services to folium tile layers.

    Returns:
        dict: A dictionary of folium tile layers.
    """
    folium_dict = {}

    for key in xyz_tiles:
        name = xyz_tiles[key]["name"]
        url = xyz_tiles[key]["url"]
        attribution = xyz_tiles[key]["attribution"]
        folium_dict[key] = folium.TileLayer(
            tiles=url,
            attr=attribution,
            name=name,
            overlay=True,
            control=True,
            max_zoom=22,
        )

    for key in wms_tiles:
        name = wms_tiles[key]["name"]
        url = wms_tiles[key]["url"]
        layers = wms_tiles[key]["layers"]
        fmt = wms_tiles[key]["format"]
        transparent = wms_tiles[key]["transparent"]
        attribution = wms_tiles[key]["attribution"]
        folium_dict[key] = folium.WmsTileLayer(
            url=url,
            layers=layers,
            name=name,
            attr=attribution,
            fmt=fmt,
            transparent=transparent,
            overlay=True,
            control=True,
        )

    xyz_dict = get_xyz_dict()
    for item in xyz_dict:
        name = xyz_dict[item].name
        url = xyz_dict[item].build_url()
        attribution = xyz_dict[item].attribution
        if "max_zoom" in xyz_dict[item].keys():
            max_zoom = xyz_dict[item]["max_zoom"]
        else:
            max_zoom = 22
        folium_dict[name] = folium.TileLayer(
            tiles=url,
            attr=attribution,
            name=name,
            max_zoom=max_zoom,
            overlay=True,
            control=True,
        )

    if os.environ.get("PLANET_API_KEY") is not None:

        planet_dict = planet_tiles(tile_format="folium")
        folium_dict.update(planet_dict)

    return folium_dict
示例#13
0
    p = folium.PolyLine(get_coordinates(bbox),
                        color='#009933',
                        weight=1,
                        opacity=0.2)

    p.add_to(m)

    if plot_sat:
        marker_cluster2 = MarkerCluster(name='Satellite images')
        marker_cluster2.add_to(m)
        url = 'http://hfrnet.ucsd.edu/thredds/wms/HFRNet/USEGC/6km/hourly/RTV'
        w1 = folium.WmsTileLayer(url,
                                 name='HF Radar',
                                 fmt='image/png',
                                 layers='surface_sea_water_velocity',
                                 attr='HFRNet',
                                 overlay=True,
                                 transparent=True)

        w1.add_to(marker_cluster2)

        url = 'http://oos.soest.hawaii.edu/thredds/wms/hioos/satellite/dhw_5km'
        w0 = folium.WmsTileLayer(url,
                                 name='Sea Surface Temperature',
                                 fmt='image/png',
                                 layers='CRW_SST',
                                 attr='PacIOOS TDS',
                                 overlay=True,
                                 transparent=True)
示例#14
0
    title = wms.title
    lon = (wms.boundingBox[0] + wms.boundingBox[2]) / 2.0
    lat = (wms.boundingBox[1] + wms.boundingBox[3]) / 2.0
    time = wms.defaulttimeposition
else:
    layer = "G1_SST_US_WEST_COAST/analysed_sst"
    title = "Sea Surface Temperature"
    lon, lat = -122.50, 39.50
    time = "undefined"

import folium

m = folium.Map(location=[lat, lon], zoom_start=4)

folium.WmsTileLayer(
    name="{} at {}".format(title, time),
    url=url,
    layers=layer,
    fmt="image/png",
    transparent=True,
).add_to(m)

folium.LayerControl().add_to(m)

m

Last but not least a static image for the page thumbnail.

from IPython.display import Image

Image(m._to_png())
示例#15
0
                            'bubblingMouseEvents': False
                        })
    gj.add_child(popup)
    gj.add_to(counties_group)

# state park geojson features
# folium.GeoJson(
#     state_parks,
#     name='State Parks',
#     style_function = lambda feature: {'fillColor': '#00ffffff','color': '#545454', 'weight': 1.5,'dashArray': '5, 5'},
#     highlight_function = lambda feature: {'fillColor': '#848484','color': 'green', 'weight': 3,'dashArray': '5, 5'}).add_child(folium.Popup('jason is the coolest')).add_to(m)

# wms layers from geoserver pi
folium.WmsTileLayer(url='http://10.10.11.66:8080/geoserver/tnris/wms',
                    name='State Parks',
                    layers='tnris:TPWD State Parks',
                    transparent=True,
                    fmt='image/png',
                    attr='TPWD').add_to(m)

folium.WmsTileLayer(url='http://10.10.11.66:8080/geoserver/tnris/wms',
                    name='Wildlife Management Areas',
                    layers='tnris:Wildlife Management Areas',
                    transparent=True,
                    fmt='image/png',
                    attr='TPWD').add_to(m)

# mesowest stations for travis county
mesowest_url = 'http://api.mesowest.net/v2/stations/metadata?&state=tx&county=Travis&token=demotoken'
mesowest_data = get(mesowest_url).json()

marker_cluster = MarkerCluster(
示例#16
0
        attr="Esri",
        name="Esri Physical Map",
        overlay=True,
        control=True,
    ),
    "Bing VirtualEarth": folium.TileLayer(
        tiles="http://ecn.t3.tiles.virtualearth.net/tiles/a{q}.jpeg?g=1",
        attr="Microsoft",
        name="Bing VirtualEarth",
        overlay=True,
        control=True,
    ),
    "3DEP Elevation": folium.WmsTileLayer(
        url="https://elevation.nationalmap.gov/arcgis/services/3DEPElevation/ImageServer/WMSServer?",
        layers="3DEPElevation:None",
        attr="USGS",
        name="3DEP Elevation",
        overlay=True,
        control=True,
    ),
    "NAIP Imagery": folium.WmsTileLayer(
        url="https://services.nationalmap.gov/arcgis/services/USGSNAIPImagery/ImageServer/WMSServer?",
        layers="0",
        attr="USGS",
        name="NAIP Imagery",
        overlay=True,
        control=True,
    ),
}


class Map(folium.Map):
示例#17
0
    create_folium_map,
    read_gpx_file,
    add_segment_to_map,
)
line_options = {'weight': 8}

the_map = create_folium_map(tiles='kartverket_topo4')

for track in read_gpx_file('example3.gpx'):
    for i, segment in enumerate(track['segments']):
        add_segment_to_map(the_map, segment, line_options=line_options)

steepness = folium.WmsTileLayer(
    url='https://gis3.nve.no/map/services/Bratthet/MapServer/WmsServer',
    layers='Bratthet_snoskred',
    fmt='image/png',
    opacity=0.7,
    transparent=True,
    name='Steepness',
)
steepness.add_to(the_map)


# Add some custom code to show a legend:
class Legend(MacroElement):
    """Just add a hard-coded legend template."""
    _template = Template(u"""
        {% macro header(this,kwargs) %}
            <style>
                .info {
                    padding: 6px 8px;
                    font: 14px/16px Arial, Helvetica, sans-serif;