|
340 | 340 | "source": [ |
341 | 341 | "from owslib.wfs import WebFeatureService\n", |
342 | 342 | "\n", |
343 | | - "wfs_url = 'https://ahocevar.com/geoserver/wfs'\n", |
| 343 | + "wfs_url = 'https://demo.mapserver.org/cgi-bin/wfs'\n", |
344 | 344 | "\n", |
345 | 345 | "wfs = WebFeatureService(wfs_url, version='2.0.0')" |
346 | 346 | ] |
|
372 | 372 | "cell_type": "markdown", |
373 | 373 | "metadata": {}, |
374 | 374 | "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" |
376 | 376 | ] |
377 | 377 | }, |
378 | 378 | { |
|
447 | 447 | }, |
448 | 448 | "outputs": [], |
449 | 449 | "source": [ |
450 | | - "wfs.get_schema('ne:ne_10m_populated_places')" |
| 450 | + "wfs.get_schema('ms:continents')" |
451 | 451 | ] |
452 | 452 | }, |
453 | 453 | { |
|
460 | 460 | }, |
461 | 461 | "outputs": [], |
462 | 462 | "source": [ |
463 | | - "wfs.contents['usa:states'].boundingBox" |
| 463 | + "wfs.contents['ms:cities'].boundingBox" |
464 | 464 | ] |
465 | 465 | }, |
466 | 466 | { |
|
484 | 484 | "* `filter`: this allows you to filter out data, basically like SQL\n", |
485 | 485 | "* `outputFormat`: download the data in various Vector data formats (default GML)\n", |
486 | 486 | "\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", |
488 | 488 | "Tip: see https://gist.github.com/graydon/11198540 for country bounding boxes.\n", |
489 | 489 | "\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" |
491 | 491 | ] |
492 | 492 | }, |
493 | 493 | { |
|
500 | 500 | }, |
501 | 501 | "outputs": [], |
502 | 502 | "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))" |
504 | 504 | ] |
505 | 505 | }, |
506 | 506 | { |
|
511 | 511 | } |
512 | 512 | }, |
513 | 513 | "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!)" |
515 | 515 | ] |
516 | 516 | }, |
517 | 517 | { |
|
524 | 524 | }, |
525 | 525 | "outputs": [], |
526 | 526 | "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", |
529 | 529 | "\tout.write(str(response.read(), 'UTF-8'))" |
530 | 530 | ] |
531 | 531 | }, |
|
578 | 578 | }, |
579 | 579 | "outputs": [], |
580 | 580 | "source": [ |
581 | | - "from owslib.fes import PropertyIsLike\n", |
| 581 | + "from owslib.fes import PropertyIsEqualTo\n", |
582 | 582 | "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", |
584 | 584 | "\n", |
585 | | - "filter_ = PropertyIsLike(propertyname='NAME', literal='Curitiba', wildCard='*')\n", |
| 585 | + "filter_ = PropertyIsEqualTo(propertyname='NAME', literal='Buenos Aires')\n", |
586 | 586 | "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)" |
588 | 589 | ] |
589 | 590 | }, |
590 | 591 | { |
|
653 | 654 | }, |
654 | 655 | "outputs": [], |
655 | 656 | "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", |
657 | 658 | "json_str = str(response.read(), 'UTF-8')\n", |
| 659 | + "\n", |
658 | 660 | "import json\n", |
659 | 661 | "parsed = json.loads(json_str)\n", |
660 | 662 | "print(json.dumps(parsed, indent=2, sort_keys=True))" |
|
949 | 951 | "name": "python", |
950 | 952 | "nbconvert_exporter": "python", |
951 | 953 | "pygments_lexer": "ipython3", |
952 | | - "version": "3.10.12" |
| 954 | + "version": "3.12.3" |
953 | 955 | } |
954 | 956 | }, |
955 | 957 | "nbformat": 4, |
|
0 commit comments