Name | cog2h3 JSON |
Version |
0.0.3
JSON |
| download |
home_page | None |
Summary | Command line script to convert Cloud Optimized Geotiff to h3 cells and insert to PosgreSQL |
upload_time | 2024-08-22 07:24:41 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | GPL-3.0-only |
keywords |
h3
index
postgresql
cog
tiff
raster
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
### Cloud Optimized Geotiff to H3 Cell
This script processes Cloud Optimized GeoTIFFs (COGs) and converts them to H3 hexagonal grids, storing the results in a PostgreSQL database. It supports multi-band rasters, resampling, and various processing options.
## Features
- Download and process COGs from URLs
- Convert raster data to H3 hexagons
- Support for multi-band rasters
- Customizable H3 resolution
- Various resampling methods
- Option to preserve raster value range during resampling
- Efficient database storage using PostgreSQL
## Prerequisites
- Python 3.7+
- PostgreSQL database
- Ensure your input COG is in WGS 1984 projection. If not, reproject it using gdalwarp
```shell
gdalwarp -overwrite input.tif output.tif -s_srs EPSG:32645 -t_srs EPSG:4326
```
- Set nodata values to 0 using `gdalwarp`,
```shell
gdalwarp -dstnodata 0 input.tif output.tif
```
- Convert a GeoTIFF to COG format:
```shell
gdal_translate -of COG input.tif output_cog.tif
```
**This all preprocessing step is included in `./pre.sh` bash script**
## Environment Variables
Set the following environment variables or use default values:
- `DATABASE_URL`: PostgreSQL connection string (default: "postgresql://postgres:postgres@localhost:5432/postgres")
- `STATIC_DIR`: Directory to store downloaded COGs (default: "static")
Example:
```shell
export DATABASE_URL="postgresql://user:password@host:port/database"
export STATIC_DIR="/path/to/cog/storage"
```
## Usage
Run the script with the following command:
```shell
python cog2h3.py --cog <COG_URL> --table <TABLE_NAME> [OPTIONS]
```
### Required Arguments:
- `--cog`: URL of the Cloud Optimized GeoTIFF (must be in WGS84 projection)
- `--table`: Name of the database table to store results
### Optional Arguments:
- `--res`: H3 resolution level (default: 8)
- `--preserve_range`: Preserve the value range of the raster while resampling
- `--multiband`: Process all bands of a multi-band raster
- `--sample_by`: Resampling method (default: "bilinear")
Available resampling methods: nearest, bilinear, cubic, cubic_spline, lanczos, average, mode, gauss, max, min, med, q1, q3, sum, rms
### Example:
```shell
python cog2h3.py --cog my-cog.tif --table cog_h3 --res 8
```
## Contribute
Contributions are Welcome ! स्वागतम
Raw data
{
"_id": null,
"home_page": null,
"name": "cog2h3",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "h3, index, postgresql, cog, tiff, raster",
"author": null,
"author_email": "Kshitij Raj Sharma <skshitizraj@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/f0/c8/c011489625de432fb629a41ea2ac4f205607dc85610ce9249c99805a6a86/cog2h3-0.0.3.tar.gz",
"platform": null,
"description": "### Cloud Optimized Geotiff to H3 Cell\n\nThis script processes Cloud Optimized GeoTIFFs (COGs) and converts them to H3 hexagonal grids, storing the results in a PostgreSQL database. It supports multi-band rasters, resampling, and various processing options.\n\n## Features\n\n- Download and process COGs from URLs\n- Convert raster data to H3 hexagons\n- Support for multi-band rasters\n- Customizable H3 resolution\n- Various resampling methods\n- Option to preserve raster value range during resampling\n- Efficient database storage using PostgreSQL\n\n## Prerequisites\n\n- Python 3.7+\n- PostgreSQL database\n\n- Ensure your input COG is in WGS 1984 projection. If not, reproject it using gdalwarp\n\n```shell\ngdalwarp -overwrite input.tif output.tif -s_srs EPSG:32645 -t_srs EPSG:4326\n```\n\n- Set nodata values to 0 using `gdalwarp`, \n```shell\ngdalwarp -dstnodata 0 input.tif output.tif\n```\n\n- Convert a GeoTIFF to COG format:\n```shell\ngdal_translate -of COG input.tif output_cog.tif\n```\n\n**This all preprocessing step is included in `./pre.sh` bash script**\n\n## Environment Variables\n\nSet the following environment variables or use default values:\n\n- `DATABASE_URL`: PostgreSQL connection string (default: \"postgresql://postgres:postgres@localhost:5432/postgres\")\n- `STATIC_DIR`: Directory to store downloaded COGs (default: \"static\")\n\nExample:\n```shell\nexport DATABASE_URL=\"postgresql://user:password@host:port/database\"\nexport STATIC_DIR=\"/path/to/cog/storage\"\n```\n## Usage\n\nRun the script with the following command:\n```shell\npython cog2h3.py --cog <COG_URL> --table <TABLE_NAME> [OPTIONS]\n```\n### Required Arguments:\n\n- `--cog`: URL of the Cloud Optimized GeoTIFF (must be in WGS84 projection)\n- `--table`: Name of the database table to store results\n\n### Optional Arguments:\n\n- `--res`: H3 resolution level (default: 8)\n- `--preserve_range`: Preserve the value range of the raster while resampling\n- `--multiband`: Process all bands of a multi-band raster\n- `--sample_by`: Resampling method (default: \"bilinear\")\n\nAvailable resampling methods: nearest, bilinear, cubic, cubic_spline, lanczos, average, mode, gauss, max, min, med, q1, q3, sum, rms\n\n### Example:\n```shell\npython cog2h3.py --cog my-cog.tif --table cog_h3 --res 8\n```\n\n## Contribute \n\nContributions are Welcome ! \u0938\u094d\u0935\u093e\u0917\u0924\u092e\n\n\n",
"bugtrack_url": null,
"license": "GPL-3.0-only",
"summary": "Command line script to convert Cloud Optimized Geotiff to h3 cells and insert to PosgreSQL",
"version": "0.0.3",
"project_urls": {
"documentation": "https://github.com/kshitijrajsharma/cog2h3",
"homepage": "https://github.com/kshitijrajsharma/cog2h3",
"repository": "https://github.com/kshitijrajsharma/cog2h3"
},
"split_keywords": [
"h3",
" index",
" postgresql",
" cog",
" tiff",
" raster"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "516a80a39f9c07accc8a4423c6ff261019a133f06625b201acf3faca11a78e47",
"md5": "e7d5d46d384b5ce275eab944c6c27e62",
"sha256": "284abd3f85a1c1148e119d7ad5966fe9b5a7fd25ae80eab344a0e0d8a8d22fe9"
},
"downloads": -1,
"filename": "cog2h3-0.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e7d5d46d384b5ce275eab944c6c27e62",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 18674,
"upload_time": "2024-08-22T07:24:39",
"upload_time_iso_8601": "2024-08-22T07:24:39.884768Z",
"url": "https://files.pythonhosted.org/packages/51/6a/80a39f9c07accc8a4423c6ff261019a133f06625b201acf3faca11a78e47/cog2h3-0.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f0c8c011489625de432fb629a41ea2ac4f205607dc85610ce9249c99805a6a86",
"md5": "38e4f416714aad805e34200b5f0a992b",
"sha256": "19f70660052ba640dad0d8f4fd71a24ccff83fc3f7d1d3c1302ceff0ace210e6"
},
"downloads": -1,
"filename": "cog2h3-0.0.3.tar.gz",
"has_sig": false,
"md5_digest": "38e4f416714aad805e34200b5f0a992b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 17885,
"upload_time": "2024-08-22T07:24:41",
"upload_time_iso_8601": "2024-08-22T07:24:41.118996Z",
"url": "https://files.pythonhosted.org/packages/f0/c8/c011489625de432fb629a41ea2ac4f205607dc85610ce9249c99805a6a86/cog2h3-0.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-22 07:24:41",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kshitijrajsharma",
"github_project": "cog2h3",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "cog2h3"
}