{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "## WFS Constructor\n", "\n", "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). \n", "\n", "The resulting layer can then be used as any other ipyleaflet GeoJSON layer." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from ipyleaflet import Map\n", "\n", "from birdy import IpyleafletWFS\n", "\n", "\n", "# Create connection\n", "url = \"http://boreas.ouranos.ca/geoserver/wfs\"\n", "version = \"2.0.0\"\n", "\n", "wfs = IpyleafletWFS(url, version)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create the map instance\n", "m = Map(center=(47.90, -69.90), zoom=11)\n", "m" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# List the available layers\n", "wfs.layer_list" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Create wfs layer\n", "# Move and zoom to the desired extent before running this cell\n", "# Do NOT zoom too far out, as large GeoJSON layers can be long to load and even cause crashed\n", "basin_style = {\n", " \"color\": \"#d000ff\",\n", " \"opacity\": 1,\n", " \"dashArray\": \"10\",\n", " \"fillOpacity\": 0.0,\n", " \"weight\": 3,\n", "}\n", "lake_style = {\"color\": \"#00aeff\", \"dashArray\": \"0\", \"fillOpacity\": 0.5, \"weight\": 0.5}\n", "\n", "lakes = wfs.create_wfsgeojson_layer(\"public:HydroLAKES_poly\", m, layer_style=lake_style)\n", "basins = wfs.create_wfsgeojson_layer(\"public:wshed_bound_n2\", m, layer_style=basin_style)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Add the layer to the map\n", "m.add_layer(basins)\n", "m.add_layer(lakes)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "m" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.8.2 64-bit", "language": "python", "name": "python38264bit57889edd0eab4a17997795fc66e6397d" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.3-final" } }, "nbformat": 4, "nbformat_minor": 2 }