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.


In [1]:
from birdy import IpyleafletWFS
from ipyleaflet import Map

# Create connection
url = 'http://boreas.ouranos.ca/geoserver/wfs'
version = '2.0.0'

wfs = IpyleafletWFS(url, version)

In [2]:
# Create the map instance
m = Map(center=(47.90, -69.90), zoom=11)
m



In [3]:
# List the available layers
wfs.layer_list


Out[3]:
['TravisTest:NE_Admin_Level0',
 'TravisTest:Provinces_États_Global',
 'TravisTest:mrc_poly',
 'TravisTest:region_admin_poly',
 'public:CANOPEX_5797_basinBoundaries',
 'public:CanVec_Rivers',
 'public:CanVec_WaterBodies',
 'public:HydroLAKES_points',
 'public:HydroLAKES_poly',
 'public:USGS_HydroBASINS_lake_ar_lev12',
 'public:USGS_HydroBASINS_lake_na_lev12',
 'public:canada_admin_boundaries',
 'public:global_admin_boundaries',
 'public:usa_admin_boundaries',
 'public:wshed_bound_n1',
 'public:wshed_bound_n2',
 'public:wshed_bound_n3']

In [4]:
# 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)

In [5]:
# Add the layer to the map
m.add_layer(basins)
m.add_layer(lakes)

In [6]:
m



In [ ]: