Skip to content

Commit 6d6dfa7

Browse files
committed
Section 10: update WFS example
1 parent ed010b8 commit 6d6dfa7

1 file changed

Lines changed: 18 additions & 16 deletions

File tree

workshop/jupyter/content/notebooks/10-remote-data.ipynb

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@
340340
"source": [
341341
"from owslib.wfs import WebFeatureService\n",
342342
"\n",
343-
"wfs_url = 'https://ahocevar.com/geoserver/wfs'\n",
343+
"wfs_url = 'https://demo.mapserver.org/cgi-bin/wfs'\n",
344344
"\n",
345345
"wfs = WebFeatureService(wfs_url, version='2.0.0')"
346346
]
@@ -372,7 +372,7 @@
372372
"cell_type": "markdown",
373373
"metadata": {},
374374
"source": [
375-
"Check the [Capabilities response](https://ahocevar.com/geoserver/wfs?service=WFS&request=GetCapabilities&version=2.0.0) directly from the server"
375+
"Check the [Capabilities response](https://demo.mapserver.org/cgi-bin/wfs?service=WFS&request=GetCapabilities&version=2.0.0) directly from the server"
376376
]
377377
},
378378
{
@@ -447,7 +447,7 @@
447447
},
448448
"outputs": [],
449449
"source": [
450-
"wfs.get_schema('ne:ne_10m_populated_places')"
450+
"wfs.get_schema('ms:continents')"
451451
]
452452
},
453453
{
@@ -460,7 +460,7 @@
460460
},
461461
"outputs": [],
462462
"source": [
463-
"wfs.contents['usa:states'].boundingBox"
463+
"wfs.contents['ms:cities'].boundingBox"
464464
]
465465
},
466466
{
@@ -484,10 +484,10 @@
484484
"* `filter`: this allows you to filter out data, basically like SQL\n",
485485
"* `outputFormat`: download the data in various Vector data formats (default GML)\n",
486486
"\n",
487-
"Example. Download all \"populated places\" within the bounding box of Estonia as GML using the `GetFeature` operation.\n",
487+
"Example. Download all \"populated places\" within the bounding box of Bosnia and Herzegovina and as GML using the `GetFeature` operation.\n",
488488
"Tip: see https://gist.github.com/graydon/11198540 for country bounding boxes.\n",
489489
"\n",
490-
"`OWSLib` will switch the axis order from EN to NE automatically if designated by EPSG-Registry.\n"
490+
"`OWSLib` will switch the axis order from EN to NE automatically if designated by the EPSG Registry.\n"
491491
]
492492
},
493493
{
@@ -500,7 +500,7 @@
500500
},
501501
"outputs": [],
502502
"source": [
503-
"response = wfs.getfeature(typename='ne:ne_10m_populated_places', bbox=(-73.9872354804, -33.7683777809, -34.7299934555, 5.24448639569))"
503+
"response = wfs.getfeature(typename='ms:cities', bbox=(15.7500260759, 42.65, 19.59976, 45.2337767604))"
504504
]
505505
},
506506
{
@@ -511,7 +511,7 @@
511511
}
512512
},
513513
"source": [
514-
"Now download in a more handy format like GeoJSON (mind: not all WFS-es support alternative output formats!)"
514+
"Now download the dataset in a more handy format like GeoJSON (note: not all WFS servers support alternative output formats!)"
515515
]
516516
},
517517
{
@@ -524,8 +524,8 @@
524524
},
525525
"outputs": [],
526526
"source": [
527-
"response = wfs.getfeature(typename='ne:ne_10m_populated_places', bbox=(-73.9872354804, -33.7683777809, -34.7299934555, 5.24448639569), outputFormat='json')\n",
528-
"with open('test/10-populated-places-ee.json', 'w', encoding='UTF-8') as out:\n",
527+
"response = wfs.getfeature(typename='ms:cities', bbox=(15.7500260759, 42.65, 19.59976, 45.2337767604), outputFormat='GeoJSON')\n",
528+
"with open('test/10-populated-places-ba.json', 'w', encoding='UTF-8') as out:\n",
529529
"\tout.write(str(response.read(), 'UTF-8'))"
530530
]
531531
},
@@ -578,13 +578,14 @@
578578
},
579579
"outputs": [],
580580
"source": [
581-
"from owslib.fes import PropertyIsLike\n",
581+
"from owslib.fes import PropertyIsEqualTo\n",
582582
"from owslib.etree import etree\n",
583-
"wfs11 = WebFeatureService(url='https://ahocevar.com/geoserver/wfs?', version='1.1.0')\n",
583+
"wfs11 = WebFeatureService(url='https://demo.mapserver.org/cgi-bin/wfs', version='1.1.0')\n",
584584
"\n",
585-
"filter_ = PropertyIsLike(propertyname='NAME', literal='Curitiba', wildCard='*')\n",
585+
"filter_ = PropertyIsEqualTo(propertyname='NAME', literal='Buenos Aires')\n",
586586
"filterxml = etree.tostring(filter_.toXML()).decode('utf-8')\n",
587-
"response = wfs11.getfeature(typename='ne:ne_10m_populated_places', filter=filterxml)"
587+
"filterxml = f'<ogc:Filter>{filterxml}</ogc:Filter>'\n",
588+
"response = wfs11.getfeature(typename='ms:cities', filter=filterxml)"
588589
]
589590
},
590591
{
@@ -653,8 +654,9 @@
653654
},
654655
"outputs": [],
655656
"source": [
656-
"response = wfs11.getfeature(typename='ne:ne_10m_populated_places', filter=filterxml, outputFormat='json')\n",
657+
"response = wfs11.getfeature(typename='ms:cities', filter=filterxml, outputFormat='GeoJSON')\n",
657658
"json_str = str(response.read(), 'UTF-8')\n",
659+
"\n",
658660
"import json\n",
659661
"parsed = json.loads(json_str)\n",
660662
"print(json.dumps(parsed, indent=2, sort_keys=True))"
@@ -949,7 +951,7 @@
949951
"name": "python",
950952
"nbconvert_exporter": "python",
951953
"pygments_lexer": "ipython3",
952-
"version": "3.10.12"
954+
"version": "3.12.3"
953955
}
954956
},
955957
"nbformat": 4,

0 commit comments

Comments
 (0)