Metadata-Version: 2.4
Name: digitalarzengine
Version: 0.4.21
Summary: DigitalArzEngine for GEE, raster and vector data processing
Author: Ather Ashraf
Author-email: atherashraf@gmail.com
Keywords: raster,vector,digital earth engine
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
Requires-Dist: affine~=2.4.0
Requires-Dist: aiobotocore~=2.23.2
Requires-Dist: aiohappyeyeballs~=2.6.1
Requires-Dist: aiohttp~=3.12.14
Requires-Dist: aioitertools~=0.12.0
Requires-Dist: aiosignal~=1.4.0
Requires-Dist: annotated-types~=0.7.0
Requires-Dist: anyio~=4.9.0
Requires-Dist: async-timeout~=5.0.1
Requires-Dist: attrs~=25.3.0
Requires-Dist: backports.tarfile~=1.2.0
Requires-Dist: boto3~=1.39.8
Requires-Dist: botocore~=1.39.8
Requires-Dist: bounded-pool-executor~=0.0.3
Requires-Dist: cachetools~=5.5.2
Requires-Dist: certifi~=2025.7.14
Requires-Dist: cffi~=1.17.1
Requires-Dist: charset-normalizer~=3.4.2
Requires-Dist: click~=8.1.8
Requires-Dist: click-plugins~=1.1.1.2
Requires-Dist: cligj~=0.7.2
Requires-Dist: color-operations~=0.2.0
Requires-Dist: cryptography~=42.0.8
Requires-Dist: docutils~=0.21.2
Requires-Dist: earthaccess~=0.11.0
Requires-Dist: earthengine-api~=0.1.419
Requires-Dist: exceptiongroup~=1.3.0
Requires-Dist: folium~=0.20.0
Requires-Dist: frozenlist~=1.7.0
Requires-Dist: fsspec~=2025.7.0
Requires-Dist: GeoAlchemy2~=0.17.1
Requires-Dist: geopandas~=1.0.1
Requires-Dist: google-api-core~=2.25.1
Requires-Dist: google-api-python-client~=2.177.0
Requires-Dist: google-auth~=2.40.3
Requires-Dist: google-auth-httplib2~=0.2.0
Requires-Dist: google-cloud-core~=2.4.3
Requires-Dist: google-cloud-storage~=3.2.0
Requires-Dist: google-crc32c~=1.7.1
Requires-Dist: google-resumable-media~=2.7.2
Requires-Dist: googleapis-common-protos~=1.70.0
Requires-Dist: h11~=0.16.0
Requires-Dist: httpcore~=1.0.9
Requires-Dist: httplib2~=0.22.0
Requires-Dist: httpx~=0.28.1
Requires-Dist: id~=1.5.0
Requires-Dist: idna~=3.10
Requires-Dist: imageio~=2.37.0
Requires-Dist: importlib_metadata~=8.7.0
Requires-Dist: importlib_resources~=6.5.2
Requires-Dist: iniconfig~=2.1.0
Requires-Dist: jaraco.classes~=3.4.0
Requires-Dist: jaraco.context~=6.0.1
Requires-Dist: jaraco.functools~=4.2.1
Requires-Dist: Jinja2~=3.1.6
Requires-Dist: jmespath~=1.0.1
Requires-Dist: keyring~=25.6.0
Requires-Dist: lazy_loader~=0.4
Requires-Dist: mapbox-vector-tile~=2.2.0
Requires-Dist: markdown-it-py~=3.0.0
Requires-Dist: MarkupSafe~=3.0.2
Requires-Dist: mdurl~=0.1.2
Requires-Dist: mercantile~=1.2.1
Requires-Dist: more-itertools~=10.7.0
Requires-Dist: morecantile~=6.2.0
Requires-Dist: multidict~=6.6.3
Requires-Dist: multimethod~=2.0
Requires-Dist: networkx~=3.2.1
Requires-Dist: nh3~=0.3.0
Requires-Dist: numexpr~=2.10.2
Requires-Dist: numpy~=1.26.4
Requires-Dist: packaging~=25.0
Requires-Dist: pandas~=2.3.1
Requires-Dist: pillow~=11.3.0
Requires-Dist: pluggy~=1.6.0
Requires-Dist: pqdm~=0.2.0
Requires-Dist: propcache~=0.3.2
Requires-Dist: proto-plus~=1.26.1
Requires-Dist: pyasn1~=0.6.1
Requires-Dist: pyasn1_modules~=0.4.2
Requires-Dist: pycparser~=2.22
Requires-Dist: pydantic~=2.10.6
Requires-Dist: pydantic_core~=2.27.2
Requires-Dist: Pygments~=2.19.2
Requires-Dist: pyogrio~=0.11.0
Requires-Dist: pyparsing~=3.2.3
Requires-Dist: pyproj~=3.7.2
Requires-Dist: pystac~=1.10.1
Requires-Dist: python-cmr~=0.13.0
Requires-Dist: python-dateutil~=2.9.0
Requires-Dist: python-dotenv~=1.1.1
Requires-Dist: pytz~=2025.2
Requires-Dist: PyYAML~=6.0.2
Requires-Dist: rasterio~=1.4.4
Requires-Dist: rio-cogeo~=7.0.1
Requires-Dist: readme_renderer~=44.0
Requires-Dist: requests~=2.32.4
Requires-Dist: requests-toolbelt~=1.0.0
Requires-Dist: responses~=0.25.7
Requires-Dist: rfc3986~=2.0.0
Requires-Dist: rich~=14.1.0
Requires-Dist: rsa~=4.9.1
Requires-Dist: s3fs~=2025.7.0
Requires-Dist: s3transfer~=0.13.1
Requires-Dist: scikit-image~=0.24.0
Requires-Dist: scipy~=1.13.1
Requires-Dist: shapely~=2.1.2
Requires-Dist: six~=1.17.0
Requires-Dist: sniffio~=1.3.1
Requires-Dist: SQLAlchemy~=2.0.41
Requires-Dist: tifffile~=2024.8.30
Requires-Dist: tinynetrc~=1.3.1
Requires-Dist: tomli~=2.2.1
Requires-Dist: tqdm~=4.67.1
Requires-Dist: typing_extensions~=4.14.1
Requires-Dist: tzdata~=2025.2
Requires-Dist: uritemplate~=4.2.0
Requires-Dist: urllib3~=1.26.20
Requires-Dist: utils~=1.0.2
Requires-Dist: Werkzeug~=3.1.3
Requires-Dist: wrapt~=1.17.2
Requires-Dist: xarray~=2024.7.0
Requires-Dist: xmltodict~=0.14.2
Requires-Dist: yarl~=1.20.1
Requires-Dist: zipp~=3.23.0
Requires-Dist: GDAL
Requires-Dist: opencv-python~=4.10.0.84
Requires-Dist: whitebox~=2.3.6
Requires-Dist: matplotlib~=3.10.8
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: keywords
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# DigitalArzEngine

**DigitalArzEngine** is a Python library designed to streamline raster data processing by extending the capabilities of the [`rasterio`](https://rasterio.readthedocs.io/) library. It provides a suite of tools for efficient geospatial transformations, mosaicing, and analysis, making it ideal for researchers, analysts, and developers working with geospatial raster data.

## 🚀 Features

- **Mosaicing:** Seamlessly merge multiple raster datasets into a unified output.
- **Summary Statistics:** Extract key metrics such as minimum, maximum, mean, and standard deviation from raster layers.
- **Reprojection & Resampling:** Transform raster datasets to different coordinate systems and resolutions with ease.
- **Clipping & Masking:** Apply geometric masks or clip rasters to specific regions of interest.
- **Pixel-wise Analysis:** Enable pixel-level operations for customized raster computations.
- **Efficient I/O Handling:** Support for reading, writing, and converting between various raster formats.

## 📦 Installation

To install the library using pip:

```bash
pip install digitalarzengine
```

---

## 📚 DataManager Utility Class

The `DataManager` class is a powerful and modular tool for handling geospatial data using SQLite databases. It supports structured storage of JSON records alongside geometric data (as WKB), with metadata tracking, querying, and integration with `GeoPandas`.

### ✅ Benefits and Usage

- **Structured Storage**: Stores geospatial records (geometry + attributes) in a portable `.db` format.
- **Metadata Management**: Tracks field names, geometry columns, and record counts.
- **Geometry Support**: Accepts and stores geometries as WKB with support for reprojection to EPSG:4326.
- **Integration with GeoPandas**: Easily convert the stored data into DataFrames and GeoDataFrames.
- **Custom Query Support**: Run filtered SQL queries and retrieve results as structured pandas objects.
- **Extendable Schema**: Dynamically add and update fields in your dataset.

### 🔧 Example Use-Cases

- Saving extracted geospatial features from remote sensing workflows.
- Iteratively storing geospatial model outputs with spatial context.
- Lightweight local spatial database for machine learning input.

### 🔄 Core Methods

- `add_record`, `update_record`, `delete_record`, `get_record`
- `get_data_as_df`, `get_data_as_gdf`, `get_gdf_list_under_aoi`
- `record_exists`, `change_key`, `add_column`, `update_column`
- Context manager support (`with DataManager(...) as dm:`)

This utility class is designed to complement the raster processing tools in `DigitalArzEngine`, making it easier to work with both raster and vector data consistently.

---

## 🗃️ DBManager Utility Class

The `DBManager` class provides a secure and flexible way to interact with PostgreSQL/PostGIS databases. It builds SQLAlchemy engines from settings and supports reading data directly into Pandas or GeoPandas.

### ✅ Benefits and Usage

- **Secure Configuration**: Pulls database credentials from a centralized encrypted config using `CryptoUtils`.
- **Flexible Access**: Supports multiple environments or databases through the `from_config` method.
- **SQLAlchemy Integration**: Simplifies connection management and avoids hardcoding sensitive details.
- **Read GeoData**: Loads spatial tables directly into `GeoDataFrame` using `read_postgis`.
- **Exclude Geometry When Needed**: Supports reading attribute-only tables as plain DataFrames.

### 🔧 Example Use-Cases

```python
    import os
from digitalarzengine.settings import DATA_DIR
from digitalarzengine.adapters.data_manager import DataManager

output_dir = os.path.join(DATA_DIR, 'pak', 'snow_cover/stats')
data_manager = DataManager(output_dir, base_name="snow_cover_normal_data",
                           purpose="snow cover normal data from 2001 to 2024")
data_manager.add_record("key_value", {})
```
- Connecting securely to remote geospatial databases for querying.
- Reading and processing large PostGIS tables as GeoDataFrames.
- Integrating web dashboards or data pipelines with PostgreSQL/PostGIS backends.

### 🔄 Core Methods

- `from_config(db_key)`: Load credentials and settings from `DATABASES`
- `get_engine()`: Return SQLAlchemy engine object
- `read_as_geo_dataframe()`: Read spatial data into GeoDataFrame
- `read_as_dataframe()`: Read tabular data with option to exclude geometry
- `get_geometry_columns()`: Identify spatial fields in the schema

### ⚙️ Configuration Example

Below is a sample `DATABASES` configuration dictionary to be placed in `digitalarzengine/settings.py`:

```python
DATABASES = {
    "drm": {
        "ENGINE": "postgresql+psycopg2",
        "NAME": "drm",
        "USER": "dafast",
        "PASSWORD": "***********************************",
        "HOST": os.getenv("DB_HOST", "localhost"),
        "PORT": "5432",
    }
}
```

> ⚠️ Note: The password here is shown encrypted. It should be decrypted using `CryptoUtils` at runtime.

The `DBManager` is ideal for scenarios where spatial data needs to be read or processed securely from enterprise databases, complementing local `DataManager` workflows.

For more advanced usage patterns and custom queries, see the source or documentation site (coming soon).

## 👨‍💻 Developed by

**Ather Ashraf**
Geospatial Data Scientist and AI Specialist

* 📧 Email: [atherashraf@gmail.com](mailto:atherashraf@gmail.com)
* 🌐 LinkedIn: [https://sa.linkedin.com/in/ather-ashraf](https://sa.linkedin.com/in/ather-ashraf)
* 📜 Google Scholar: [View Profile](https://scholar.google.com.pk/citations?user=XbqhyrsAAAAJ&hl=en)
* 📱 WhatsApp: +966557252342 | +923224785104

---
