|
14 | 14 | "metadata": {}, |
15 | 15 | "outputs": [], |
16 | 16 | "source": [ |
17 | | - "import geoengine as ge\n", |
18 | | - "import geoengine_openapi_client\n", |
19 | 17 | "from datetime import datetime\n", |
| 18 | + "\n", |
| 19 | + "import geoengine_openapi_client\n", |
| 20 | + "\n", |
| 21 | + "import geoengine as ge\n", |
20 | 22 | "from geoengine.types import RasterBandDescriptor" |
21 | 23 | ] |
22 | 24 | }, |
|
110 | 112 | "\n", |
111 | 113 | "file_not_found_handling = geoengine_openapi_client.FileNotFoundHandling.NODATA\n", |
112 | 114 | "\n", |
113 | | - "gdal_params = geoengine_openapi_client.GdalDatasetParameters.from_dict({\n", |
114 | | - " \"filePath\": file_path,\n", |
115 | | - " \"rasterbandChannel\": rasterband_channel,\n", |
116 | | - " \"geoTransform\": geo_transform.to_api_dict(),\n", |
117 | | - " \"width\": width,\n", |
118 | | - " \"height\": height,\n", |
119 | | - " \"fileNotFoundHandling\": file_not_found_handling,\n", |
120 | | - " \"noDataValue\": None,\n", |
121 | | - " \"propertiesMapping\": None,\n", |
122 | | - " \"gdalOpenOptions\": None,\n", |
123 | | - " \"gdalConfigOptions\": None,\n", |
124 | | - " \"allowAlphabandAsMask\": True\n", |
125 | | - "})\n", |
| 115 | + "gdal_params = geoengine_openapi_client.GdalDatasetParameters.from_dict(\n", |
| 116 | + " {\n", |
| 117 | + " \"filePath\": file_path,\n", |
| 118 | + " \"rasterbandChannel\": rasterband_channel,\n", |
| 119 | + " \"geoTransform\": geo_transform.to_api_dict(),\n", |
| 120 | + " \"width\": width,\n", |
| 121 | + " \"height\": height,\n", |
| 122 | + " \"fileNotFoundHandling\": file_not_found_handling,\n", |
| 123 | + " \"noDataValue\": None,\n", |
| 124 | + " \"propertiesMapping\": None,\n", |
| 125 | + " \"gdalOpenOptions\": None,\n", |
| 126 | + " \"gdalConfigOptions\": None,\n", |
| 127 | + " \"allowAlphabandAsMask\": True,\n", |
| 128 | + " }\n", |
| 129 | + ")\n", |
126 | 130 | "\n", |
127 | 131 | "result_descriptor_measurement = ge.ClassificationMeasurement(\n", |
128 | 132 | " measurement=\"Land Cover\",\n", |
|
143 | 147 | " \"13\": \"Urban and Built-Up\",\n", |
144 | 148 | " \"14\": \"Cropland-Natural Vegetation Mosaics\",\n", |
145 | 149 | " \"15\": \"Snow and Ice\",\n", |
146 | | - " \"16\": \"Barren or Sparsely Vegetated\"\n", |
147 | | - " }\n", |
148 | | - "\n", |
| 150 | + " \"16\": \"Barren or Sparsely Vegetated\",\n", |
| 151 | + " },\n", |
149 | 152 | ")\n", |
150 | 153 | "\n", |
151 | 154 | "\n", |
|
154 | 157 | " [RasterBandDescriptor(\"band\", result_descriptor_measurement)],\n", |
155 | 158 | " \"EPSG:4326\",\n", |
156 | 159 | " spatial_bounds=ge.SpatialPartition2D(-180.0, -90.0, 180.0, 90.0),\n", |
157 | | - " spatial_resolution=ge.SpatialResolution(0.1, 0.1)\n", |
| 160 | + " spatial_resolution=ge.SpatialResolution(0.1, 0.1),\n", |
158 | 161 | ")\n", |
159 | 162 | "\n", |
160 | | - "meta_data = geoengine_openapi_client.GdalMetaDataStatic.from_dict({\n", |
161 | | - " \"type\": \"GdalStatic\",\n", |
162 | | - " \"time\": None,\n", |
163 | | - " \"params\": gdal_params,\n", |
164 | | - " \"resultDescriptor\": result_descriptor.to_api_dict().to_dict(),\n", |
165 | | - "})\n", |
| 163 | + "meta_data = geoengine_openapi_client.GdalMetaDataStatic.from_dict(\n", |
| 164 | + " {\n", |
| 165 | + " \"type\": \"GdalStatic\",\n", |
| 166 | + " \"time\": None,\n", |
| 167 | + " \"params\": gdal_params,\n", |
| 168 | + " \"resultDescriptor\": result_descriptor.to_api_dict().to_dict(),\n", |
| 169 | + " }\n", |
| 170 | + ")\n", |
166 | 171 | "\n", |
167 | 172 | "meta_data" |
168 | 173 | ] |
169 | 174 | }, |
170 | 175 | { |
171 | 176 | "cell_type": "code", |
172 | | - "execution_count": 5, |
| 177 | + "execution_count": null, |
173 | 178 | "metadata": {}, |
174 | 179 | "outputs": [ |
175 | 180 | { |
|
197 | 202 | " breakpoints=[\n", |
198 | 203 | " ge.ColorBreakpoint(value=0, color=(0, 0, 255, 255)),\n", |
199 | 204 | " ge.ColorBreakpoint(value=8, color=(0, 255, 0, 255)),\n", |
200 | | - " ge.ColorBreakpoint(value=16, color=(255, 0, 0, 255))\n", |
| 205 | + " ge.ColorBreakpoint(value=16, color=(255, 0, 0, 255)),\n", |
201 | 206 | " ],\n", |
202 | 207 | " no_data_color=(0, 0, 0, 0),\n", |
203 | 208 | " over_color=(0, 0, 0, 0),\n", |
204 | | - " under_color=(0, 0, 0, 0)\n", |
205 | | - " )\n", |
206 | | - " )\n", |
| 209 | + " under_color=(0, 0, 0, 0),\n", |
| 210 | + " ),\n", |
| 211 | + " ),\n", |
207 | 212 | " ),\n", |
208 | | - " provenance=[ge.Provenance(\n", |
209 | | - " citation=\"The data was obtained from <https://lpdaac.usgs.gov/products/mcd12c1v006>. The layer Majority_Land_Cover_Type_1 was extracted, downscaled and saved as landcover.tif.\",\n", |
210 | | - " uri=\"https://lpdaac.usgs.gov/products/mcd12c1v006/\",\n", |
211 | | - " license=\"All data distributed by the LP DAAC contain no restrictions on the data reuse. (https://lpdaac.usgs.gov/resources/faqs/#am-i-allowed-to-reuse-lp-daac-data).\"\n", |
212 | | - " )],\n", |
213 | | - "\n", |
214 | | - "\n", |
| 213 | + " provenance=[\n", |
| 214 | + " ge.Provenance(\n", |
| 215 | + " citation=\"The data was obtained from <https://lpdaac.usgs.gov/products/mcd12c1v006>. The layer Majority_Land_Cover_Type_1 was extracted, downscaled and saved as landcover.tif.\", # noqa: E501\n", |
| 216 | + " uri=\"https://lpdaac.usgs.gov/products/mcd12c1v006/\",\n", |
| 217 | + " license=\"All data distributed by the LP DAAC contain no restrictions on the data reuse. (https://lpdaac.usgs.gov/resources/faqs/#am-i-allowed-to-reuse-lp-daac-data).\",\n", |
| 218 | + " )\n", |
| 219 | + " ],\n", |
215 | 220 | ")\n", |
216 | 221 | "\n", |
217 | 222 | "add_dataset_properties.to_api_dict()" |
|
280 | 285 | } |
281 | 286 | ], |
282 | 287 | "source": [ |
283 | | - "ge.datasets.list_datasets(name_filter='MCD12C1')" |
| 288 | + "ge.datasets.list_datasets(name_filter=\"MCD12C1\")" |
284 | 289 | ] |
285 | 290 | }, |
286 | 291 | { |
|
314 | 319 | "ge.reset()\n", |
315 | 320 | "ge.initialize(\"http://localhost:3030/api\")\n", |
316 | 321 | "\n", |
317 | | - "workflow = ge.register_workflow({\n", |
318 | | - " \"type\": \"Raster\",\n", |
319 | | - " \"operator\": {\n", |
320 | | - " \"type\": \"GdalSource\",\n", |
321 | | - " \"params\": {\n", |
322 | | - " \"data\": \"MCD12C1\",\n", |
323 | | - " }\n", |
| 322 | + "workflow = ge.register_workflow(\n", |
| 323 | + " {\n", |
| 324 | + " \"type\": \"Raster\",\n", |
| 325 | + " \"operator\": {\n", |
| 326 | + " \"type\": \"GdalSource\",\n", |
| 327 | + " \"params\": {\n", |
| 328 | + " \"data\": \"MCD12C1\",\n", |
| 329 | + " },\n", |
| 330 | + " },\n", |
324 | 331 | " }\n", |
325 | | - "})\n", |
| 332 | + ")\n", |
326 | 333 | "\n", |
327 | 334 | "workflow.get_result_descriptor()" |
328 | 335 | ] |
|
370 | 377 | } |
371 | 378 | ], |
372 | 379 | "source": [ |
373 | | - "time = datetime.strptime(\n", |
374 | | - " '2014-04-01T12:00:00.000Z', \"%Y-%m-%dT%H:%M:%S.%f%z\")\n", |
| 380 | + "time = datetime.strptime(\"2014-04-01T12:00:00.000Z\", \"%Y-%m-%dT%H:%M:%S.%f%z\")\n", |
375 | 381 | "\n", |
376 | 382 | "data = workflow.get_xarray(\n", |
377 | 383 | " ge.QueryRectangle(\n", |
378 | 384 | " ge.BoundingBox2D(-180.0, -90.0, 180.0, 90.0),\n", |
379 | 385 | " ge.TimeInterval(time, time),\n", |
380 | | - " resolution=ge.SpatialResolution(360. / 16, 180. / 16),\n", |
| 386 | + " resolution=ge.SpatialResolution(360.0 / 16, 180.0 / 16),\n", |
381 | 387 | " )\n", |
382 | 388 | ")\n", |
383 | 389 | "\n", |
|
439 | 445 | " ge.QueryRectangle(\n", |
440 | 446 | " ge.BoundingBox2D(-180.0, -90.0, 180.0, 90.0),\n", |
441 | 447 | " ge.TimeInterval(time, time),\n", |
442 | | - " resolution=ge.SpatialResolution(360. / 16, 180. / 16),\n", |
| 448 | + " resolution=ge.SpatialResolution(360.0 / 16, 180.0 / 16),\n", |
443 | 449 | " )\n", |
444 | 450 | " )\n", |
445 | 451 | "except Exception as e:\n", |
|
0 commit comments