geobox 2.0.0__py3-none-any.whl → 2.1.0__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.
- geobox/aio/analysis.py +757 -0
- geobox/aio/api.py +103 -4
- geobox/aio/query.py +0 -9
- geobox/aio/raster.py +1273 -869
- geobox/aio/task.py +1 -1
- geobox/aio/usage.py +1 -1
- geobox/aio/vectorlayer.py +109 -2
- geobox/aio/workflow.py +1 -1
- geobox/analysis.py +757 -0
- geobox/api.py +104 -6
- geobox/enums.py +402 -348
- geobox/query.py +1 -10
- geobox/raster.py +1270 -863
- geobox/task.py +1 -1
- geobox/vectorlayer.py +107 -2
- geobox/view.py +2 -2
- {geobox-2.0.0.dist-info → geobox-2.1.0.dist-info}/METADATA +1 -1
- {geobox-2.0.0.dist-info → geobox-2.1.0.dist-info}/RECORD +21 -19
- {geobox-2.0.0.dist-info → geobox-2.1.0.dist-info}/WHEEL +0 -0
- {geobox-2.0.0.dist-info → geobox-2.1.0.dist-info}/licenses/LICENSE +0 -0
- {geobox-2.0.0.dist-info → geobox-2.1.0.dist-info}/top_level.txt +0 -0
geobox/api.py
CHANGED
|
@@ -2,9 +2,11 @@ import requests
|
|
|
2
2
|
import logging
|
|
3
3
|
import os
|
|
4
4
|
from urllib.parse import urljoin
|
|
5
|
-
from typing import Dict, List, Union
|
|
5
|
+
from typing import Dict, List, Optional, Union
|
|
6
6
|
from datetime import datetime
|
|
7
7
|
|
|
8
|
+
from geobox.enums import AnalysisDataType, AnalysisResampleMethod
|
|
9
|
+
|
|
8
10
|
from .exception import AuthenticationError, ApiRequestError, NotFoundError, ValidationError, ServerError, AuthorizationError
|
|
9
11
|
from .vectorlayer import VectorLayer, LayerType
|
|
10
12
|
from .feature import Feature
|
|
@@ -134,7 +136,6 @@ class _RequestSession(requests.Session):
|
|
|
134
136
|
kwargs['headers'] = request_headers
|
|
135
137
|
|
|
136
138
|
try:
|
|
137
|
-
print(kwargs['headers'])
|
|
138
139
|
response = super().request(method, url, **kwargs)
|
|
139
140
|
finally:
|
|
140
141
|
if original_content_type:
|
|
@@ -327,7 +328,6 @@ class GeoboxClient:
|
|
|
327
328
|
|
|
328
329
|
try:
|
|
329
330
|
if files:
|
|
330
|
-
print(files)
|
|
331
331
|
response = self.session.request(method, url, data=payload, files=files)
|
|
332
332
|
elif is_json:
|
|
333
333
|
response = self.session.request(method, url, json=payload)
|
|
@@ -746,7 +746,7 @@ class GeoboxClient:
|
|
|
746
746
|
return VectorLayerView.get_views_by_ids(self, ids, user_id, include_settings)
|
|
747
747
|
|
|
748
748
|
|
|
749
|
-
def get_view(self, uuid: str) -> 'VectorLayerView':
|
|
749
|
+
def get_view(self, uuid: str, user_id: int = None) -> 'VectorLayerView':
|
|
750
750
|
"""
|
|
751
751
|
Get a specific vector layer view by its UUID.
|
|
752
752
|
|
|
@@ -762,7 +762,7 @@ class GeoboxClient:
|
|
|
762
762
|
>>> client = GeoboxClient()
|
|
763
763
|
>>> view = client.get_view(uuid="12345678-1234-5678-1234-567812345678")
|
|
764
764
|
"""
|
|
765
|
-
return VectorLayerView.get_view(self, uuid)
|
|
765
|
+
return VectorLayerView.get_view(self, uuid, user_id)
|
|
766
766
|
|
|
767
767
|
|
|
768
768
|
def get_view_by_name(self, name: str, user_id: int = None) -> Union['VectorLayerView', None]:
|
|
@@ -2620,4 +2620,102 @@ class GeoboxClient:
|
|
|
2620
2620
|
>>> client = GeoboxClient()
|
|
2621
2621
|
>>> client.update_usage()
|
|
2622
2622
|
"""
|
|
2623
|
-
return Usage.update_usage(self, user_id=user_id)
|
|
2623
|
+
return Usage.update_usage(self, user_id=user_id)
|
|
2624
|
+
|
|
2625
|
+
|
|
2626
|
+
def raster_calculator(self,
|
|
2627
|
+
variables: str,
|
|
2628
|
+
expr: str,
|
|
2629
|
+
output_raster_name: str,
|
|
2630
|
+
match_raster_uuid: Optional[str] = None,
|
|
2631
|
+
resample: AnalysisResampleMethod = AnalysisResampleMethod.bilinear,
|
|
2632
|
+
out_dtype: AnalysisDataType = AnalysisDataType.float32,
|
|
2633
|
+
dst_nodata: int = -9999,
|
|
2634
|
+
user_id: Optional[int] = None) -> 'Task':
|
|
2635
|
+
"""
|
|
2636
|
+
Perform raster calculator operations on multiple raster datasets.
|
|
2637
|
+
|
|
2638
|
+
it allows you to perform mathematical operations on one or more raster datasets using NumPy expressions.
|
|
2639
|
+
Variables in the expression correspond to raster datasets specified in the variables dictionary.
|
|
2640
|
+
|
|
2641
|
+
Examples:
|
|
2642
|
+
NDVI calculation: variables='{"NIR": "raster_uuid_1", "RED": "raster_uuid_2"}', expr="(NIR-RED)/(NIR+RED)"
|
|
2643
|
+
Slope threshold: variables='{"SLOPE": "raster_uuid_1"}', expr="np.where(SLOPE>30,1,0)"
|
|
2644
|
+
Multi-band operations: variables='{"IMG": ["raster_uuid_1", 2]}', expr="IMG*2"
|
|
2645
|
+
|
|
2646
|
+
Args:
|
|
2647
|
+
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.
|
|
2648
|
+
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.
|
|
2649
|
+
output_raster_name (str): Name for the output raster dataset.
|
|
2650
|
+
match_raster_uuid (str, optional): Optional raster UUID to match the output grid and projection. If not provided, the first variable becomes the reference grid.
|
|
2651
|
+
resample (CropResample, optional): Resampling method: 'near', 'bilinear', 'cubic', 'lanczos', etc. default: CropResample.near
|
|
2652
|
+
out_dtype (AnalysisDataType, optional): Data type for the output raster (e.g., int16, float32). default: AnalysisDataType.float32
|
|
2653
|
+
dst_nodata (int, optional): NoData value for the output raster. default = -9999
|
|
2654
|
+
user_id (int, optional): specific user. priviledges required!
|
|
2655
|
+
|
|
2656
|
+
Returns:
|
|
2657
|
+
Task: task instance of the process
|
|
2658
|
+
|
|
2659
|
+
Example:
|
|
2660
|
+
>>> from geobox import GeoboxClient
|
|
2661
|
+
>>> client = GeoboxClient()
|
|
2662
|
+
>>> task = client.raster_calculator(api=client, variables={"NIR": "raster_uuid_1", "RED": "raster_uuid_2"},
|
|
2663
|
+
... expr='where(SLOPE>30,1,0)',
|
|
2664
|
+
... output_raster_name='test')
|
|
2665
|
+
"""
|
|
2666
|
+
from .analysis import Analysis
|
|
2667
|
+
return Analysis.calculator(self,
|
|
2668
|
+
variables=variables,
|
|
2669
|
+
expr=expr,
|
|
2670
|
+
output_raster_name=output_raster_name,
|
|
2671
|
+
match_raster_uuid=match_raster_uuid,
|
|
2672
|
+
resample=resample,
|
|
2673
|
+
out_dtype=out_dtype,
|
|
2674
|
+
dst_nodata=dst_nodata,
|
|
2675
|
+
user_id=user_id)
|
|
2676
|
+
|
|
2677
|
+
|
|
2678
|
+
|
|
2679
|
+
def create_constant_raster(self,
|
|
2680
|
+
output_raster_name: str,
|
|
2681
|
+
extent: str,
|
|
2682
|
+
value : int,
|
|
2683
|
+
pixel_size: int = 10,
|
|
2684
|
+
dtype: AnalysisDataType = AnalysisDataType.float32,
|
|
2685
|
+
nodata: int = -9999,
|
|
2686
|
+
align_to: Optional[str] = None,
|
|
2687
|
+
user_id: Optional[int] = None) -> 'Task':
|
|
2688
|
+
"""
|
|
2689
|
+
Create a raster filled with a constant value.
|
|
2690
|
+
|
|
2691
|
+
This endpoint creates a north-up GeoTIFF filled with a constant value.
|
|
2692
|
+
Only users with Publisher role or higher can perform this operation.
|
|
2693
|
+
|
|
2694
|
+
Args:
|
|
2695
|
+
output_raster_name (str): Name for the output constant raster dataset.
|
|
2696
|
+
extent (str): Extent as 'minX,minY,maxX,maxY' (e.g., '0,0,100,100').
|
|
2697
|
+
value (int): Constant value to fill the raster with.
|
|
2698
|
+
pixel_size (int, optional): Pixel size for the output raster (must be > 0). default: 10
|
|
2699
|
+
dtype (AnalysisDataType, optoinal): Output data type. default: AnalysisDataType.float32
|
|
2700
|
+
nodata (int, optional): NoData value for the raster. default: -9999
|
|
2701
|
+
align_to (str, optional): Grid origin to snap to as 'x0,y0' (e.g., '0,0').
|
|
2702
|
+
user_id (int, optional): specific user. priviledges required!
|
|
2703
|
+
|
|
2704
|
+
Returns:
|
|
2705
|
+
Task: task instance of the process
|
|
2706
|
+
|
|
2707
|
+
Example:
|
|
2708
|
+
>>> from geobox import GeoboxClient
|
|
2709
|
+
>>> client = GeoboxClient()
|
|
2710
|
+
>>> task = client.create_constant_raster(output_raster_name='test', extent='0,0,100,100', value=10)
|
|
2711
|
+
"""
|
|
2712
|
+
from .analysis import Analysis
|
|
2713
|
+
return Analysis.constant(self,
|
|
2714
|
+
output_raster_name=output_raster_name,
|
|
2715
|
+
extent=extent,
|
|
2716
|
+
value=value,
|
|
2717
|
+
pixel_size=pixel_size,
|
|
2718
|
+
dtype=dtype,
|
|
2719
|
+
nodata=nodata,
|
|
2720
|
+
align_to=align_to,
|
|
2721
|
+
user_id=user_id)
|