geobox 2.1.0__py3-none-any.whl → 2.2.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. geobox/__init__.py +61 -63
  2. geobox/aio/__init__.py +61 -63
  3. geobox/aio/api.py +491 -574
  4. geobox/aio/apikey.py +263 -263
  5. geobox/aio/attachment.py +341 -339
  6. geobox/aio/base.py +261 -262
  7. geobox/aio/basemap.py +196 -196
  8. geobox/aio/dashboard.py +340 -342
  9. geobox/aio/feature.py +35 -35
  10. geobox/aio/field.py +315 -321
  11. geobox/aio/file.py +72 -72
  12. geobox/aio/layout.py +340 -341
  13. geobox/aio/log.py +23 -23
  14. geobox/aio/map.py +1033 -1034
  15. geobox/aio/model3d.py +415 -415
  16. geobox/aio/mosaic.py +696 -696
  17. geobox/aio/plan.py +314 -314
  18. geobox/aio/query.py +693 -693
  19. geobox/aio/raster.py +88 -454
  20. geobox/aio/{analysis.py → raster_analysis.py} +153 -170
  21. geobox/aio/route.py +4 -4
  22. geobox/aio/scene.py +340 -342
  23. geobox/aio/settings.py +18 -18
  24. geobox/aio/task.py +404 -402
  25. geobox/aio/tile3d.py +337 -339
  26. geobox/aio/tileset.py +102 -103
  27. geobox/aio/usage.py +52 -51
  28. geobox/aio/user.py +506 -507
  29. geobox/aio/vector_tool.py +1968 -0
  30. geobox/aio/vectorlayer.py +316 -414
  31. geobox/aio/version.py +272 -273
  32. geobox/aio/view.py +1019 -983
  33. geobox/aio/workflow.py +340 -341
  34. geobox/api.py +14 -98
  35. geobox/apikey.py +262 -262
  36. geobox/attachment.py +336 -337
  37. geobox/base.py +384 -384
  38. geobox/basemap.py +194 -194
  39. geobox/dashboard.py +339 -341
  40. geobox/enums.py +31 -1
  41. geobox/feature.py +31 -10
  42. geobox/field.py +320 -320
  43. geobox/file.py +4 -4
  44. geobox/layout.py +339 -340
  45. geobox/log.py +4 -4
  46. geobox/map.py +1031 -1032
  47. geobox/model3d.py +410 -410
  48. geobox/mosaic.py +696 -696
  49. geobox/plan.py +313 -313
  50. geobox/query.py +691 -691
  51. geobox/raster.py +5 -368
  52. geobox/{analysis.py → raster_analysis.py} +108 -128
  53. geobox/scene.py +341 -342
  54. geobox/settings.py +194 -194
  55. geobox/task.py +399 -400
  56. geobox/tile3d.py +337 -338
  57. geobox/tileset.py +4 -4
  58. geobox/usage.py +3 -3
  59. geobox/user.py +503 -503
  60. geobox/vector_tool.py +1968 -0
  61. geobox/vectorlayer.py +5 -110
  62. geobox/version.py +272 -272
  63. geobox/view.py +981 -981
  64. geobox/workflow.py +338 -339
  65. {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/METADATA +15 -1
  66. geobox-2.2.1.dist-info/RECORD +72 -0
  67. geobox-2.1.0.dist-info/RECORD +0 -70
  68. {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/WHEEL +0 -0
  69. {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/licenses/LICENSE +0 -0
  70. {geobox-2.1.0.dist-info → geobox-2.2.1.dist-info}/top_level.txt +0 -0
@@ -1,26 +1,26 @@
1
- from typing import List, Dict, Optional, TYPE_CHECKING, Union
1
+ from typing import Dict, Optional, TYPE_CHECKING, Union
2
2
 
3
3
  from geobox.field import Field
4
4
 
5
- from .vectorlayer import VectorLayer
6
- from .view import VectorLayerView
5
+ from .vectorlayer import AsyncVectorLayer
6
+ from .view import AsyncVectorLayerView
7
7
  from .base import AsyncBase
8
- from .raster import Raster
8
+ from .raster import AsyncRaster
9
9
  from ..enums import (AnalysisDataType, PolygonizeConnectivity, AnalysisResampleMethod,
10
10
  SlopeUnit, AnalysisAlgorithm, RangeBound, DistanceUnit)
11
11
  from ..utils import clean_data
12
12
 
13
13
  if TYPE_CHECKING:
14
14
  from . import AsyncGeoboxClient
15
- from .task import Task
15
+ from .task import AsyncTask
16
16
 
17
- class Analysis(AsyncBase):
17
+ class AsyncRasterAnalysis(AsyncBase):
18
18
 
19
19
  BASE_ENDPOINT = 'analysis/'
20
20
 
21
21
  def __init__(self,
22
- api: 'AsyncGeoboxClient',
23
- data: Optional[Dict] = {}):
22
+ api: 'AsyncGeoboxClient',
23
+ data: Optional[Dict] = {}):
24
24
  """
25
25
  [async] Initialize a workflow instance.
26
26
 
@@ -33,19 +33,18 @@ class Analysis(AsyncBase):
33
33
 
34
34
 
35
35
  def __repr__(self) -> str:
36
- return f"Analysis()"
36
+ return f"AsyncRasterAnalysis()"
37
37
 
38
- @classmethod
39
- async def rasterize(cls,
40
- api: 'AsyncGeoboxClient',
41
- layer: Union[VectorLayer, VectorLayerView],
38
+
39
+ async def rasterize(self,
40
+ layer: Union[AsyncVectorLayer, AsyncVectorLayerView],
42
41
  output_raster_name: str,
43
42
  pixel_size: int = 10,
44
43
  nodata: Optional[int] = -9999,
45
44
  data_type: Optional[AnalysisDataType] = AnalysisDataType.int16,
46
45
  burn_value: Optional[int] = 1,
47
46
  burn_attribute: Optional[str] = None,
48
- user_id: Optional[int] = None) -> 'Task':
47
+ user_id: Optional[int] = None) -> 'AsyncTask':
49
48
  """
50
49
  [async] Rasterize a vector layer
51
50
 
@@ -54,8 +53,7 @@ class Analysis(AsyncBase):
54
53
  Only users with Publisher role or higher can perform this operation.
55
54
 
56
55
  Args:
57
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests
58
- layer (VectorLayer | VectorLayerView): VectorLayer or VectorLayerView instance
56
+ layer (AsyncVectorLayer | AsyncVectorLayerView): VectorLayer or VectorLayerView instance
59
57
  output_raster_name (str): Name for the output raster dataset
60
58
  pixel_size (int, optional): Pixel size for the output raster (must be > 0). default: 10
61
59
  nodata (int, optional): NoData value to use in the output raster. default: -9999
@@ -65,26 +63,27 @@ class Analysis(AsyncBase):
65
63
  user_id (int, optional): specific user. priviledges required!
66
64
 
67
65
  Returns:
68
- Task: task instance of the process
66
+ AsyncTask: task instance of the process
69
67
 
70
68
  Example:
71
69
  >>> from geobox.aio import AsyncGeoboxClient
72
- >>> from geobox.aio.raster_analysis import Analysis
70
+ >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis
73
71
  >>> async with AsyncGeoboxClient() as client:
74
72
  >>> vector = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
75
- >>> task = await Analysis.rasterize(api=client, layer=vector, output_raster_name='test')
73
+ >>> task = await client.raster_analysis.rasterize(layer=vector, output_raster_name='test')
76
74
  or
77
- >>> task = await vector.rasterize(output_raster_name='test')
75
+ >>> raster_analysis = AsyncRasterAnalysis(client)
76
+ >>> task = await raster_analysis.rasterize(layer=vector, output_raster_name='test')
78
77
  """
79
- if not isinstance(layer, VectorLayer) and not isinstance(layer, VectorLayerView):
78
+ if not isinstance(layer, AsyncVectorLayer) and not isinstance(layer, AsyncVectorLayerView):
80
79
  raise ValueError("'layer' input only accepts vector layer and view objects!")
81
80
 
82
- endpoint = f'{cls.BASE_ENDPOINT}rasterize/'
81
+ endpoint = f'{self.BASE_ENDPOINT}rasterize/'
83
82
 
84
83
  data = clean_data({
85
84
  'layer_uuid': layer.uuid,
86
85
  'output_raster_name': output_raster_name,
87
- 'is_view': False if isinstance(layer, VectorLayer) else True,
86
+ 'is_view': False if isinstance(layer, AsyncVectorLayer) else True,
88
87
  'pixel_size': pixel_size,
89
88
  'nodata': nodata,
90
89
  'data_type': data_type.value,
@@ -93,14 +92,12 @@ class Analysis(AsyncBase):
93
92
  'user_id': user_id
94
93
  })
95
94
 
96
- response = await api.post(endpoint=endpoint, payload=data, is_json=False)
97
- return await api.get_task(response['task_id'])
95
+ response = await self.api.post(endpoint=endpoint, payload=data, is_json=False)
96
+ return await self.api.get_task(response['task_id'])
98
97
 
99
98
 
100
- @classmethod
101
- async def polygonize(cls,
102
- api: 'AsyncGeoboxClient',
103
- raster: 'Raster',
99
+ async def polygonize(self,
100
+ raster: 'AsyncRaster',
104
101
  output_layer_name: str,
105
102
  band_index: int = 1,
106
103
  value_field: Optional[str] = None,
@@ -108,14 +105,13 @@ class Analysis(AsyncBase):
108
105
  connectivity: PolygonizeConnectivity = PolygonizeConnectivity.connected_4,
109
106
  keep_values: Optional[str] = None,
110
107
  layer_name: Optional[str] = None,
111
- user_id: Optional[int] = None) -> 'Task':
108
+ user_id: Optional[int] = None) -> 'AsyncTask':
112
109
  """
113
110
  [async] Convert a raster to vector polygons
114
111
 
115
112
  vectorizes a raster (polygonize) to a vector dataset (*.gpkg). Only users with Publisher role or higher can perform this operation
116
113
 
117
114
  Args:
118
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests
119
115
  raster (Raster): Raster instance
120
116
  output_layer_name (str): Name for the output vector layer.
121
117
  band_index (int, optional): Raster band to polygonize. default: 1
@@ -127,18 +123,19 @@ class Analysis(AsyncBase):
127
123
  user_id (int, optional): specific user. priviledges required!
128
124
 
129
125
  Returns:
130
- Task: task instance of the process
126
+ AsyncTask: task instance of the process
131
127
 
132
128
  Example:
133
129
  >>> from geobox.aio import AsyncGeoboxClient
134
- >>> from geobox.aio.raster_analysis import Analysis
130
+ >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis
135
131
  >>> async with AsyncGeoboxClient() as client:
136
132
  >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678")
137
- >>> task = await Analysis.polygonize(api=client, raster=raster, output_layer_name='test')
133
+ >>> task = await client.raster_analysis.polygonize(raster=raster, output_layer_name='test')
138
134
  or
139
- >>> task = await raster.polygonize(output_layer_name='test')
135
+ >>> raster_analysis = AsyncRasterAnalysis(client)
136
+ >>> task = await raster_analysis.polygonize(raster=raster, output_layer_name='test')
140
137
  """
141
- endpoint = f'{cls.BASE_ENDPOINT}polygonize/'
138
+ endpoint = f'{self.BASE_ENDPOINT}polygonize/'
142
139
 
143
140
  data = clean_data({
144
141
  'raster_uuid': raster.uuid,
@@ -152,30 +149,27 @@ class Analysis(AsyncBase):
152
149
  'user_id': user_id
153
150
  })
154
151
 
155
- response = await api.post(endpoint=endpoint, payload=data, is_json=False)
156
- return await api.get_task(response['task_id'])
152
+ response = await self.api.post(endpoint=endpoint, payload=data, is_json=False)
153
+ return await self.api.get_task(response['task_id'])
157
154
 
158
155
 
159
- @classmethod
160
- async def clip(cls,
161
- api: 'AsyncGeoboxClient',
162
- raster: 'Raster',
163
- layer: Union[VectorLayer, VectorLayerView],
156
+ async def clip(self,
157
+ raster: 'AsyncRaster',
158
+ layer: Union[AsyncVectorLayer, AsyncVectorLayerView],
164
159
  output_raster_name: str,
165
160
  where: Optional[str] = None,
166
161
  dst_nodata: int = -9999,
167
162
  crop: bool = True,
168
163
  resample: AnalysisResampleMethod = AnalysisResampleMethod.near,
169
- user_id: Optional[int] = None) -> 'Task':
164
+ user_id: Optional[int] = None) -> 'AsyncTask':
170
165
  """
171
166
  [async] Clip a raster using a vector layer as a mask
172
167
 
173
168
  clips a raster dataset using a vector layer as the clipping boundary. Only users with Publisher role or higher can perform this operation
174
169
 
175
170
  Args:
176
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests
177
171
  raster (Raster): Raster instance
178
- layer (VectorLayer | VectorLayerView): VectorLayer or VectorLayerView instance
172
+ layer (AsyncVectorLayer | AsyncVectorLayerView): VectorLayer or VectorLayerView instance
179
173
  output_raster_name (str): Name for the output raster dataset
180
174
  where (str, optional): Optional attribute filter, e.g. 'VEG=forest'.
181
175
  dst_nodata (int, optional): Output NoData value. default: -9999
@@ -184,28 +178,29 @@ class Analysis(AsyncBase):
184
178
  user_id (int, optional): specific user. priviledges required!
185
179
 
186
180
  Returns:
187
- Task: task instance of the process
181
+ AsyncTask: task instance of the process
188
182
 
189
183
  Example:
190
184
  >>> from geobox.aio import AsyncGeoboxClient
191
- >>> from geobox.aio.raster_analysis import Analysis
185
+ >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis
192
186
  >>> async with AsyncGeoboxClient() as client:
193
187
  >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678")
194
188
  >>> vector = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
195
- >>> task = await Analysis.clip(api=client, raster=raster, layer=vector, output_raster_name='test')
189
+ >>> task = await client.raster_analysis.clip(raster=raster, layer=vector, output_raster_name='test')
196
190
  or
197
- >>> task = await raster.clip(layer=vector, output_raster_name='test')
191
+ >>> raster_analysis = AsyncRasterAnalysis(client)
192
+ >>> task = await raster_analysis.clip(raster=raster, layer=vector, output_raster_name='test')
198
193
  """
199
- if not isinstance(layer, VectorLayer) and not isinstance(layer, VectorLayerView):
194
+ if not isinstance(layer, AsyncVectorLayer) and not isinstance(layer, AsyncVectorLayerView):
200
195
  raise ValueError("'layer' input only accepts vector layer and view objects!")
201
196
 
202
- endpoint = f'{cls.BASE_ENDPOINT}clip/'
197
+ endpoint = f'{self.BASE_ENDPOINT}clip/'
203
198
 
204
199
  data = clean_data({
205
200
  'raster_uuid': raster.uuid,
206
201
  'layer_uuid': layer.uuid,
207
202
  'output_raster_name': output_raster_name,
208
- 'is_view': False if isinstance(layer, VectorLayer) else True,
203
+ 'is_view': False if isinstance(layer, AsyncVectorLayer) else True,
209
204
  'where': where,
210
205
  'dst_nodata': dst_nodata,
211
206
  'crop': crop,
@@ -213,13 +208,11 @@ class Analysis(AsyncBase):
213
208
  'user_id': user_id
214
209
  })
215
210
 
216
- response = await api.post(endpoint=endpoint, payload=data, is_json=False)
217
- return await api.get_task(response['task_id'])
211
+ response = await self.api.post(endpoint=endpoint, payload=data, is_json=False)
212
+ return await self.api.get_task(response['task_id'])
218
213
 
219
214
 
220
- @classmethod
221
- async def calculator(cls,
222
- api: 'AsyncGeoboxClient',
215
+ async def calculator(self,
223
216
  variables: str,
224
217
  expr: str,
225
218
  output_raster_name: str,
@@ -227,7 +220,7 @@ class Analysis(AsyncBase):
227
220
  resample: AnalysisResampleMethod = AnalysisResampleMethod.bilinear,
228
221
  out_dtype: AnalysisDataType = AnalysisDataType.float32,
229
222
  dst_nodata: int = -9999,
230
- user_id: Optional[int] = None) -> 'Task':
223
+ user_id: Optional[int] = None) -> 'AsyncTask':
231
224
  """
232
225
  [async] Perform raster calculator operations on multiple raster datasets.
233
226
 
@@ -240,7 +233,6 @@ class Analysis(AsyncBase):
240
233
  Multi-band operations: variables='{"IMG": ["raster_uuid_1", 2]}', expr="IMG*2"
241
234
 
242
235
  Args:
243
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests
244
236
  variables (str): JSON string mapping variable names to raster specifications. Format: '{"NIR": "raster_uuid_1", "RED": "raster_uuid_2"}' or '{"IMG": ["raster_uuid_1", 2]}' for multi-band operations.
245
237
  expr (str): Mathematical expression using NumPy syntax. Use variable names from the variables dict, e.g., '(NIR-RED)/(NIR+RED)' or 'where(SLOPE>30,1,0)' or 'where((dist_to_highway < 1000) & (slope < 10), 1, 0)' .Supported functions: np, sin, cos, tan, asin, acos, atan, sinh, cosh, tanh, exp, log, log10, sqrt, abs, floor, ceil, round, minimum, maximum, clip, where, isnan, isfinite, pi, e.
246
238
  output_raster_name (str): Name for the output raster dataset.
@@ -251,18 +243,23 @@ class Analysis(AsyncBase):
251
243
  user_id (int, optional): specific user. priviledges required!
252
244
 
253
245
  Returns:
254
- Task: task instance of the process
246
+ AsyncTask: task instance of the process
255
247
 
256
248
  Example:
257
249
  >>> from geobox.aio import AsyncGeoboxClient
258
- >>> from geobox.aio.raster_analysis import Analysis
250
+ >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis
259
251
  >>> async with AsyncGeoboxClient() as client:
260
252
  >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678")
261
- >>> task = await Analysis.calculator(api=client, variables={"NIR": "raster_uuid_1", "RED": "raster_uuid_2"},
253
+ >>> task = await client.raster_analysis.calculator(variables={"NIR": "raster_uuid_1", "RED": "raster_uuid_2"},
254
+ ... expr='where(SLOPE>30,1,0)',
255
+ ... output_raster_name='test')
256
+ or
257
+ >>> raster_analysis = AsyncRasterAnalysis(client)
258
+ >>> task = raster_analysis.calculator(variables={"NIR": "raster_uuid_1", "RED": "raster_uuid_2"},
262
259
  ... expr='where(SLOPE>30,1,0)',
263
260
  ... output_raster_name='test')
264
261
  """
265
- endpoint = f'{cls.BASE_ENDPOINT}calculator/'
262
+ endpoint = f'{self.BASE_ENDPOINT}calculator/'
266
263
 
267
264
  data = clean_data({
268
265
  'variables': variables,
@@ -275,28 +272,25 @@ class Analysis(AsyncBase):
275
272
  'user_id': user_id
276
273
  })
277
274
 
278
- response = await api.post(endpoint=endpoint, payload=data, is_json=False)
279
- return await api.get_task(response['task_id'])
275
+ response = await self.api.post(endpoint=endpoint, payload=data, is_json=False)
276
+ return await self.api.get_task(response['task_id'])
280
277
 
281
278
 
282
- @classmethod
283
- async def slope(cls,
284
- api: 'AsyncGeoboxClient',
285
- raster: 'Raster',
279
+ async def slope(self,
280
+ raster: 'AsyncRaster',
286
281
  output_raster_name: str,
287
282
  slope_units: SlopeUnit = SlopeUnit.degree,
288
283
  algorithm: AnalysisAlgorithm = AnalysisAlgorithm.Horn,
289
284
  scale: int = 1,
290
285
  compute_edges: bool = True,
291
286
  nodata_out: int = -9999,
292
- user_id: Optional[int] = None) -> 'Task':
287
+ user_id: Optional[int] = None) -> 'AsyncTask':
293
288
  """
294
289
  [async] Calculate slope from a DEM raster.
295
290
 
296
291
  This endpoint creates a slope raster from a Digital Elevation Model (DEM). Only users with Publisher role or higher can perform this operation.
297
292
 
298
293
  Args:
299
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests
300
294
  raster (Raster): DEM Raster instance
301
295
  output_raster_name (str): Name for the output raster dataset.
302
296
  slope_units (SlopeUnit, optional): Slope units: 'degree' or 'percent'. default: SlopeUnit.degree
@@ -307,18 +301,19 @@ class Analysis(AsyncBase):
307
301
  user_id (int, optional): specific user. priviledges required!
308
302
 
309
303
  Returns:
310
- Task: task instance of the process
304
+ AsyncTask: task instance of the process
311
305
 
312
306
  Example:
313
307
  >>> from geobox.aio import AsyncGeoboxClient
314
- >>> from geobox.aio.raster_analysis import Analysis
308
+ >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis
315
309
  >>> async with AsyncGeoboxClient() as client:
316
310
  >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678")
317
- >>> task = await Analysis.slope(api=client, raster=raster, output_raster_name='test')
311
+ >>> task = await client.raster_analysis.slope(raster=raster, output_raster_name='test')
318
312
  or
319
- >>> task = await raster.slope(output_raster_name='test')
313
+ >>> raster_analysis = AsyncRasterAnalysis(client)
314
+ >>> task = await raster_analysis.slope(raster=raster, output_raster_name='test')
320
315
  """
321
- endpoint = f'{cls.BASE_ENDPOINT}slope/'
316
+ endpoint = f'{self.BASE_ENDPOINT}slope/'
322
317
 
323
318
  data = clean_data({
324
319
  'raster_uuid': raster.uuid,
@@ -331,21 +326,19 @@ class Analysis(AsyncBase):
331
326
  'user_id': user_id
332
327
  })
333
328
 
334
- response = await api.post(endpoint=endpoint, payload=data, is_json=False)
335
- return await api.get_task(response['task_id'])
329
+ response = await self.api.post(endpoint=endpoint, payload=data, is_json=False)
330
+ return await self.api.get_task(response['task_id'])
336
331
 
337
332
 
338
- @classmethod
339
- async def aspect(cls,
340
- api: 'AsyncGeoboxClient',
341
- raster: 'Raster',
333
+ async def aspect(self,
334
+ raster: 'AsyncRaster',
342
335
  output_raster_name: str,
343
336
  algorithm: AnalysisAlgorithm = AnalysisAlgorithm.Horn,
344
337
  trigonometric: bool = False,
345
338
  zero_for_flat: bool = True,
346
339
  compute_edges: bool = True,
347
340
  nodata_out: int = -9999,
348
- user_id: Optional[int] = None) -> 'Task':
341
+ user_id: Optional[int] = None) -> 'AsyncTask':
349
342
  """
350
343
  [async] Calculate aspect from a DEM raster.
351
344
 
@@ -353,7 +346,6 @@ class Analysis(AsyncBase):
353
346
  Only users with Publisher role or higher can perform this operation.
354
347
 
355
348
  Args:
356
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests
357
349
  raster (Raster): DEM Raster instance
358
350
  output_raster_name (str): Name for the output raster dataset.
359
351
  algorithm (AnalysisAlgorithm, optional): Algorithm: 'Horn' or 'ZevenbergenThorne'. default: AnalysisAlgorithm.Horn
@@ -364,19 +356,20 @@ class Analysis(AsyncBase):
364
356
  user_id (int, optional): specific user. priviledges required!
365
357
 
366
358
  Returns:
367
- Task: task instance of the process
359
+ AsyncTask: task instance of the process
368
360
 
369
361
  Example:
370
362
  >>> from geobox.aio import AsyncGeoboxClient
371
- >>> from geobox.aio.raster_analysis import Analysis
363
+ >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis
372
364
  >>> async with AsyncGeoboxClient() as client:
373
365
  >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678")
374
- >>> task = await Analysis.aspect(api=client, raster=raster, output_raster_name='test')
366
+ >>> task = await client.raster_analysis.aspect(raster=raster, output_raster_name='test')
375
367
  or
376
- >>> task = await raster.aspect(output_raster_name='test')
368
+ >>> raster_analysis = AsyncRasterAnalysis(client)
369
+ >>> task = await raster_analysis.aspect(raster=raster, output_raster_name='test')
377
370
  """
378
371
 
379
- endpoint = f'{cls.BASE_ENDPOINT}aspect/'
372
+ endpoint = f'{self.BASE_ENDPOINT}aspect/'
380
373
 
381
374
  data = clean_data({
382
375
  'raster_uuid': raster.uuid,
@@ -389,14 +382,12 @@ class Analysis(AsyncBase):
389
382
  'user_id': user_id
390
383
  })
391
384
 
392
- response = await api.post(endpoint=endpoint, payload=data, is_json=False)
393
- return await api.get_task(response['task_id'])
385
+ response = await self.api.post(endpoint=endpoint, payload=data, is_json=False)
386
+ return await self.api.get_task(response['task_id'])
394
387
 
395
388
 
396
- @classmethod
397
- async def reclassify(cls,
398
- api: 'AsyncGeoboxClient',
399
- raster: 'Raster',
389
+ async def reclassify(self,
390
+ raster: 'AsyncRaster',
400
391
  output_raster_name: str,
401
392
  rules: str,
402
393
  default_value: Optional[int] = None,
@@ -404,7 +395,7 @@ class Analysis(AsyncBase):
404
395
  nodata_out: int = -9999,
405
396
  out_dtype: AnalysisDataType = AnalysisDataType.int16,
406
397
  inclusive: RangeBound = RangeBound.left,
407
- user_id: Optional[int] = None) -> 'Task':
398
+ user_id: Optional[int] = None) -> 'AsyncTask':
408
399
  """
409
400
  [async] Reclassify a raster using value mapping or class breaks.
410
401
 
@@ -412,7 +403,6 @@ class Analysis(AsyncBase):
412
403
  Only users with Publisher role or higher can perform this operation.
413
404
 
414
405
  Args:
415
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests
416
406
  raster (Raster): Raster instance
417
407
  output_raster_name (str): Name for the output reclassified raster dataset.
418
408
  rules (str): JSON string containing reclassification rules.
@@ -429,18 +419,19 @@ class Analysis(AsyncBase):
429
419
  user_id (int, optional): specific user. priviledges required!
430
420
 
431
421
  Returns:
432
- Task: task instance of the process
422
+ AsyncTask: task instance of the process
433
423
 
434
424
  Example:
435
425
  >>> from geobox.aio import AsyncGeoboxClient
436
- >>> from geobox.aio.raster_analysis import Analysis
426
+ >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis
437
427
  >>> async with AsyncGeoboxClient() as client:
438
428
  >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678")
439
- >>> task = await Analysis.reclassify(api=client, raster=raster, output_raster_name='test', rules='{"1": 10, "2": 20, "3": 30}')
429
+ >>> task = await client.raster_analysis.reclassify(raster=raster, output_raster_name='test', rules='{"1": 10, "2": 20, "3": 30}')
440
430
  or
441
- >>> task = raster.reclassify(output_raster_name='test', rules='{"1": 10, "2": 20, "3": 30}')
431
+ >>> raster_analysis = AsyncRasterAnalysis(client)
432
+ >>> task = raster_analysis.reclassify(raster=raster, output_raster_name='test', rules='{"1": 10, "2": 20, "3": 30}')
442
433
  """
443
- endpoint = f'{cls.BASE_ENDPOINT}reclassify/'
434
+ endpoint = f'{self.BASE_ENDPOINT}reclassify/'
444
435
 
445
436
  data = clean_data({
446
437
  'raster_uuid': raster.uuid,
@@ -455,21 +446,19 @@ class Analysis(AsyncBase):
455
446
  'user_id': user_id
456
447
  })
457
448
 
458
- response = await api.post(endpoint=endpoint, payload=data, is_json=False)
459
- return await api.get_task(response['task_id'])
449
+ response = await self.api.post(endpoint=endpoint, payload=data, is_json=False)
450
+ return await self.api.get_task(response['task_id'])
460
451
 
461
452
 
462
- @classmethod
463
- async def resample(cls,
464
- api: 'AsyncGeoboxClient',
465
- raster: 'Raster',
453
+ async def resample(self,
454
+ raster: 'AsyncRaster',
466
455
  output_raster_name: str,
467
456
  out_res: Optional[str] = None,
468
457
  scale_factor: Optional[str] = None,
469
458
  match_raster_uuid: Optional[str] = None,
470
459
  resample_method: AnalysisResampleMethod = AnalysisResampleMethod.near,
471
460
  dst_nodata: int = -9999,
472
- user_id: Optional[int] = None) -> 'Task':
461
+ user_id: Optional[int] = None) -> 'AsyncTask':
473
462
  """
474
463
  [async] Resample a raster to a different resolution.
475
464
 
@@ -478,7 +467,6 @@ class Analysis(AsyncBase):
478
467
  Only users with Publisher role or higher can perform this operation.
479
468
 
480
469
  Args:
481
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests
482
470
  raster (Raster): Raster instance
483
471
  output_raster_name (str): Name for the output reclassified raster dataset.
484
472
  out_res (str, optional): Output resolution as 'x_res,y_res' (e.g., '10,10').
@@ -489,21 +477,22 @@ class Analysis(AsyncBase):
489
477
  user_id (int, optional): specific user. priviledges required!
490
478
 
491
479
  Returns:
492
- Task: task instance of the process
480
+ AsyncTask: task instance of the process
493
481
 
494
482
  Example:
495
483
  >>> from geobox.aio import AsyncGeoboxClient
496
- >>> from geobox.aio.raster_analysis import Analysis
484
+ >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis
497
485
  >>> async with AsyncGeoboxClient() as client:
498
486
  >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678")
499
- >>> task = await Analysis.resample(api=client, raster=raster, output_raster_name='test', out_res='10,10')
487
+ >>> task = await client.raster_analysis.resample(raster=raster, output_raster_name='test', out_res='10,10')
500
488
  or
501
- >>> task = await raster.resample(output_raster_name='test', out_res='10,10')
489
+ >>> raster_analysis = AsyncRasterAnalysis(client)
490
+ >>> task = await raster_analysis.resample(raster=raster, output_raster_name='test', out_res='10,10')
502
491
  """
503
492
  if sum(x is not None for x in [out_res, scale_factor, match_raster_uuid]) != 1:
504
493
  raise ValueError('Exactly one of out_res, scale_factor, or match_raster_uuid must be provided!')
505
494
 
506
- endpoint = f'{cls.BASE_ENDPOINT}resample/'
495
+ endpoint = f'{self.BASE_ENDPOINT}resample/'
507
496
 
508
497
  data = clean_data({
509
498
  'raster_uuid': raster.uuid,
@@ -516,14 +505,12 @@ class Analysis(AsyncBase):
516
505
  'user_id': user_id
517
506
  })
518
507
 
519
- response = await api.post(endpoint=endpoint, payload=data, is_json=False)
520
- return await api.get_task(response['task_id'])
508
+ response = await self.api.post(endpoint=endpoint, payload=data, is_json=False)
509
+ return await self.api.get_task(response['task_id'])
521
510
 
522
511
 
523
- @classmethod
524
- async def idw_interpolation(cls,
525
- api: 'AsyncGeoboxClient',
526
- layer: Union[VectorLayer, VectorLayerView],
512
+ async def idw_interpolation(self,
513
+ layer: Union[AsyncVectorLayer, AsyncVectorLayerView],
527
514
  output_raster_name: str,
528
515
  z_field: Field,
529
516
  match_raster_uuid: Optional[str] = None,
@@ -535,7 +522,7 @@ class Analysis(AsyncBase):
535
522
  radius: int = 1000,
536
523
  nodata: int = -9999,
537
524
  out_dtype: AnalysisDataType = AnalysisDataType.float32,
538
- user_id: Optional[int] = None) -> 'Task':
525
+ user_id: Optional[int] = None) -> 'AsyncTask':
539
526
  """
540
527
  [async] Create an IDW (Inverse Distance Weighting) interpolation raster from point data.
541
528
 
@@ -543,8 +530,7 @@ class Analysis(AsyncBase):
543
530
  Only users with Publisher role or higher can perform this operation.
544
531
 
545
532
  Args:
546
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests
547
- layer (VectorLayer | VectorLayerview): layer containing point data
533
+ layer (AsyncVectorLayer | AsyncVectorLayerview): layer containing point data
548
534
  output_raster_name (str): Name for the output IDW raster dataset.
549
535
  z_field (Field): the field containing the values to interpolate.
550
536
  match_raster_uuid (str, optional): UUID of reference raster to match resolution/extent.
@@ -559,25 +545,26 @@ class Analysis(AsyncBase):
559
545
  user_id (int, optional): specific user. priviledges required!
560
546
 
561
547
  Returns:
562
- Task: task instance of the process
548
+ AsyncTask: task instance of the process
563
549
 
564
550
  Example:
565
551
  >>> from geobox.aio import AsyncGeoboxClient
566
- >>> from geobox.aio.raster_analysis import Analysis
552
+ >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis
567
553
  >>> async with AsyncGeoboxClient() as client:
568
554
  >>> vector = await client.get_vector(uuid="12345678-1234-5678-1234-567812345678")
569
555
  >>> field = await vector.get_field_by_name('field_name')
570
- >>> task = await Analysis.idw(api=client, layer=vector, output_raster_name='test', z_field=field)
556
+ >>> task = await client.raster_analysis.idw_interpolation(layer=vector, output_raster_name='test', z_field=field)
571
557
  or
572
- >>> task = await vector.idw(output_raster_name='test', z_field=field)
558
+ >>> raster_analysis = AsyncRasterAnalysis(client)
559
+ >>> task = await raster_analysis.idw_interpolation(layer=vector, output_raster_name='test', z_field=field)
573
560
  """
574
- endpoint = f'{cls.BASE_ENDPOINT}idw/'
561
+ endpoint = f'{self.BASE_ENDPOINT}idw/'
575
562
 
576
563
  data = clean_data({
577
564
  'layer_uuid': layer.uuid,
578
565
  'output_raster_name': output_raster_name,
579
566
  'z_field': z_field.name,
580
- 'is_view': False if isinstance(layer, VectorLayer) else True,
567
+ 'is_view': False if isinstance(layer, AsyncVectorLayer) else True,
581
568
  'match_raster_uuid': match_raster_uuid,
582
569
  'pixel_size': pixel_size,
583
570
  'extent': extent,
@@ -590,13 +577,11 @@ class Analysis(AsyncBase):
590
577
  'user_id': user_id
591
578
  })
592
579
 
593
- response = await api.post(endpoint=endpoint, payload=data, is_json=False)
594
- return await api.get_task(response['task_id'])
580
+ response = await self.api.post(endpoint=endpoint, payload=data, is_json=False)
581
+ return await self.api.get_task(response['task_id'])
595
582
 
596
583
 
597
- @classmethod
598
- async def constant(cls,
599
- api: 'AsyncGeoboxClient',
584
+ async def constant(self,
600
585
  output_raster_name: str,
601
586
  extent: str,
602
587
  value : int,
@@ -604,7 +589,7 @@ class Analysis(AsyncBase):
604
589
  dtype: AnalysisDataType = AnalysisDataType.float32,
605
590
  nodata: int = -9999,
606
591
  align_to: Optional[str] = None,
607
- user_id: Optional[int] = None) -> 'Task':
592
+ user_id: Optional[int] = None) -> 'AsyncTask':
608
593
  """
609
594
  [async] Create a raster filled with a constant value.
610
595
 
@@ -612,7 +597,6 @@ class Analysis(AsyncBase):
612
597
  Only users with Publisher role or higher can perform this operation.
613
598
 
614
599
  Args:
615
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests
616
600
  output_raster_name (str): Name for the output constant raster dataset.
617
601
  extent (str): Extent as 'minX,minY,maxX,maxY' (e.g., '0,0,100,100').
618
602
  value (int): Constant value to fill the raster with.
@@ -623,15 +607,18 @@ class Analysis(AsyncBase):
623
607
  user_id (int, optional): specific user. priviledges required!
624
608
 
625
609
  Returns:
626
- Task: task instance of the process
610
+ AsyncTask: task instance of the process
627
611
 
628
612
  Example:
629
613
  >>> from geobox.aio import AsyncGeoboxClient
630
- >>> from geobox.aio.raster_analysis import Analysis
614
+ >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis
631
615
  >>> async with AsyncGeoboxClient() as client:
632
- >>> task = await Analysis.constant(api=client, output_raster_name='test', extent='0,0,100,100', value=10)
616
+ >>> task = await client.raster_analysis.constant(output_raster_name='test', extent='0,0,100,100', value=10)
617
+ or
618
+ >>> raster_analysis = AsyncRasterAnalysis(client)
619
+ >>> task = await raster_analysis.constant(output_raster_name='test', extent='0,0,100,100', value=10)
633
620
  """
634
- endpoint = f'{cls.BASE_ENDPOINT}constant/'
621
+ endpoint = f'{self.BASE_ENDPOINT}constant/'
635
622
 
636
623
  data = clean_data({
637
624
  'output_raster_name': output_raster_name,
@@ -644,21 +631,19 @@ class Analysis(AsyncBase):
644
631
  'user_id': user_id
645
632
  })
646
633
 
647
- response = await api.post(endpoint=endpoint, payload=data, is_json=False)
648
- return await api.get_task(response['task_id'])
634
+ response = await self.api.post(endpoint=endpoint, payload=data, is_json=False)
635
+ return await self.api.get_task(response['task_id'])
649
636
 
650
637
 
651
- @classmethod
652
- async def fill_nodata(cls,
653
- api: 'AsyncGeoboxClient',
654
- raster: 'Raster',
638
+ async def fill_nodata(self,
639
+ raster: 'AsyncRaster',
655
640
  output_raster_name: str,
656
641
  band: Union[int, str] = 1,
657
642
  nodata: Optional[int] = None,
658
643
  max_search_dist: Optional[int] = None,
659
644
  smoothing_iterations: Optional[int] = None,
660
645
  mask_raster_uuid: Optional[str] = None,
661
- user_id: Optional[int] = None) -> 'Task':
646
+ user_id: Optional[int] = None) -> 'AsyncTask':
662
647
  """
663
648
  [async] Fill NoData regions in a raster using GDAL's FillNodata algorithm.
664
649
 
@@ -667,7 +652,6 @@ class Analysis(AsyncBase):
667
652
  Only users with Publisher role or higher can perform this operation.
668
653
 
669
654
  Args:
670
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests
671
655
  raster (Raster): the input raster to fill NoData regions in
672
656
  output_raster_name (str): Name for the output filled raster dataset.
673
657
  band (int | str): 1-based band index to process or 'all' to process all bands. default: 1
@@ -678,18 +662,19 @@ class Analysis(AsyncBase):
678
662
  user_id (int, optional): specific user. priviledges required!
679
663
 
680
664
  Returns:
681
- Task: task instance of the process
665
+ AsyncTask: task instance of the process
682
666
 
683
667
  Example:
684
668
  >>> from geobox.aio import AsyncGeoboxClient
685
- >>> from geobox.aio.raster_analysis import Analysis
669
+ >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis
686
670
  >>> async with AsyncGeoboxClient() as client:
687
671
  >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678")
688
- >>> task = await Analysis.fill_nodata(api=client, raster=raster, output_raster_name='test')
672
+ >>> task = await client.raster_analysis.fill_nodata(raster=raster, output_raster_name='test')
689
673
  or
690
- >>> task = await raster.fill_nodata(output_raster_name='test')
674
+ >>> raster_analysis = AsyncRasterAnalysis(client)
675
+ >>> task = await raster_analyis.fill_nodata(raster=raster, output_raster_name='test')
691
676
  """
692
- endpoint = f'{cls.BASE_ENDPOINT}fill/'
677
+ endpoint = f'{self.BASE_ENDPOINT}fill/'
693
678
 
694
679
  data = clean_data({
695
680
  'raster_uuid': raster.uuid,
@@ -702,19 +687,17 @@ class Analysis(AsyncBase):
702
687
  'user_id': user_id
703
688
  })
704
689
 
705
- response = await api.post(endpoint=endpoint, payload=data, is_json=False)
706
- return await api.get_task(response['task_id'])
690
+ response = await self.api.post(endpoint=endpoint, payload=data, is_json=False)
691
+ return await self.api.get_task(response['task_id'])
707
692
 
708
693
 
709
- @classmethod
710
- async def proximity(cls,
711
- api: 'AsyncGeoboxClient',
712
- raster: 'Raster',
694
+ async def proximity(self,
695
+ raster: 'AsyncRaster',
713
696
  output_raster_name: str,
714
697
  dist_units: DistanceUnit = DistanceUnit.GEO,
715
698
  burn_value: int = 1,
716
699
  nodata: int = -9999,
717
- user_id: Optional[int] = None) -> 'Task':
700
+ user_id: Optional[int] = None) -> 'AsyncTask':
718
701
  """
719
702
  [async] Create a proximity (distance) raster from a raster layer.
720
703
 
@@ -722,7 +705,6 @@ class Analysis(AsyncBase):
722
705
  Only users with Publisher role or higher can perform this operation.
723
706
 
724
707
  Args:
725
- api (AsyncGeoboxClient): The AsyncGeoboxClient instance for making requests
726
708
  raster (Raster): the raster layer to create proximity raster from.
727
709
  output_raster_name (str): Name for the output proximity raster dataset.
728
710
  dist_units (DistanceUnit, optional): Distance units: 'GEO' for georeferenced units, 'PIXEL' for pixels. default: DistanceUnit.GEO
@@ -731,18 +713,19 @@ class Analysis(AsyncBase):
731
713
  user_id (int, optional): specific user. priviledges required!
732
714
 
733
715
  Returns:
734
- Task: task instance of the process
716
+ AsyncTask: task instance of the process
735
717
 
736
718
  Example:
737
719
  >>> from geobox.aio import AsyncGeoboxClient
738
- >>> from geobox.aio.raster_analysis import Analysis
720
+ >>> from geobox.aio.raster_analysis import AsyncRasterAnalysis
739
721
  >>> async with AsyncGeoboxClient() as client:
740
722
  >>> raster = await client.get_raster(uuid="12345678-1234-5678-1234-567812345678")
741
- >>> task = await Analysis.proximity(api=client, raster=raster, output_raster_name='test')
723
+ >>> task = await client.raster_analysis.proximity(raster=raster, output_raster_name='test')
742
724
  or
743
- >>> task = await raster.proximity(output_raster_name='test')
725
+ >>> raster_analysis = AsyncRasterAnalysis(client)
726
+ >>> task = await raster_analysis.proximity(raster=raster, output_raster_name='test')
744
727
  """
745
- endpoint = f'{cls.BASE_ENDPOINT}proximity/'
728
+ endpoint = f'{self.BASE_ENDPOINT}proximity/'
746
729
 
747
730
  data = clean_data({
748
731
  'raster_uuid': raster.uuid,
@@ -753,5 +736,5 @@ class Analysis(AsyncBase):
753
736
  'user_id': user_id
754
737
  })
755
738
 
756
- response = await api.post(endpoint=endpoint, payload=data, is_json=False)
757
- return await api.get_task(response['task_id'])
739
+ response = await self.api.post(endpoint=endpoint, payload=data, is_json=False)
740
+ return await self.api.get_task(response['task_id'])