WFS Constructor¶
This notebook is an example of the create_wfsgeojson_layer() function, for the use cases where only a GeoJSON layer is needed out of a WFS service and a certain control over the map is to be conserved (Taking away much of the automation of build_layer(), but gaining more flexibility).
The resulting layer can then be used as any other ipyleaflet GeoJSON layer.
[ ]:
from ipyleaflet import Map
from birdy import IpyleafletWFS
# Create connection
url = "http://boreas.ouranos.ca/geoserver/wfs"
version = "2.0.0"
wfs = IpyleafletWFS(url, version)
[ ]:
# Create the map instance
m = Map(center=(47.90, -69.90), zoom=11)
m
[ ]:
# List the available layers
wfs.layer_list
[ ]:
# Create wfs layer
# Move and zoom to the desired extent before running this cell
# Do NOT zoom too far out, as large GeoJSON layers can be long to load and even cause crashed
basin_style = {
"color": "#d000ff",
"opacity": 1,
"dashArray": "10",
"fillOpacity": 0.0,
"weight": 3,
}
lake_style = {"color": "#00aeff", "dashArray": "0", "fillOpacity": 0.5, "weight": 0.5}
lakes = wfs.create_wfsgeojson_layer("public:HydroLAKES_poly", m, layer_style=lake_style)
basins = wfs.create_wfsgeojson_layer("public:wshed_bound_n2", m, layer_style=basin_style)
[ ]:
# Add the layer to the map
m.add_layer(basins)
m.add_layer(lakes)
[ ]:
m