|
61 | 61 | "\n" |
62 | 62 | ] |
63 | 63 | }, |
64 | | - { |
65 | | - "cell_type": "markdown", |
66 | | - "metadata": {}, |
67 | | - "source": [ |
68 | | - "### Access via OWSLib\n", |
69 | | - "\n", |
70 | | - "Use OWSLib to access pygeoapi OGC API endpoint via Python,\n", |
71 | | - "From your locally running `pygeoapi` server, which has the address `geopython-workshop-pygeoapi`\n", |
72 | | - "within the Docker network. [Remote Data](10-remote-data.ipynb) will go into more detail on access spatial web services from Python." |
73 | | - ] |
74 | | - }, |
75 | | - { |
76 | | - "cell_type": "code", |
77 | | - "execution_count": null, |
78 | | - "metadata": { |
79 | | - "pycharm": { |
80 | | - "name": "#%%\n" |
81 | | - } |
82 | | - }, |
83 | | - "outputs": [], |
84 | | - "source": [ |
85 | | - "from owslib.ogcapi.features import Features\n", |
86 | | - "oa_feat = Features('http://geopython-workshop-pygeoapi')\n", |
87 | | - "oa_feat.links" |
88 | | - ] |
89 | | - }, |
90 | | - { |
91 | | - "cell_type": "code", |
92 | | - "execution_count": null, |
93 | | - "metadata": { |
94 | | - "pycharm": { |
95 | | - "name": "#%%\n" |
96 | | - } |
97 | | - }, |
98 | | - "outputs": [], |
99 | | - "source": [ |
100 | | - "# Get collections (datasets) in endpoint\n", |
101 | | - "collections = oa_feat.collections()\n", |
102 | | - "print(f'This OGC API Features endpoint has {len(collections)} datasets')" |
103 | | - ] |
104 | | - }, |
105 | | - { |
106 | | - "cell_type": "code", |
107 | | - "execution_count": null, |
108 | | - "metadata": { |
109 | | - "pycharm": { |
110 | | - "name": "#%%\n" |
111 | | - } |
112 | | - }, |
113 | | - "outputs": [], |
114 | | - "source": [ |
115 | | - "# Get items (paged) in Lakes collection\n", |
116 | | - "lakes = oa_feat.collection('lakes')\n", |
117 | | - "lakes_query = oa_feat.collection_items('lakes')\n", |
118 | | - "# Plot first lake\n", |
119 | | - "lake = lakes_query['features'][0]\n", |
120 | | - "print(lake.get('properties').get('name'))\n", |
121 | | - "from shapely.geometry import shape\n", |
122 | | - "lakepolygon = shape(lake.get('geometry'))\n", |
123 | | - "lakepolygon" |
124 | | - ] |
125 | | - }, |
126 | 64 | { |
127 | 65 | "cell_type": "markdown", |
128 | 66 | "metadata": {}, |
|
0 commit comments