ATL-Tools


NameATL-Tools JSON
Version 1.1.3 PyPI version JSON
download
home_pageNone
SummaryAI-Tianlong的Tools打包,开箱即用, 包含ATL_path和ATL_gdal,可用于文件夹创建、文件搜索、遥感图像处理
upload_time2024-04-18 10:36:05
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseMIT License
keywords atl_tools gdal ai-tianlong chinese
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # ATL_Tools 使用指南
## 0. 简介
ATL_Tools 是一个由 [AI-Tianlong【GitHub】](https://github.com/AI-Tianlong)开发的工具集合,包含一些便利的小工具。
如果您有新的模块添加,或者对现有模块有改进意见,欢迎提交 PR 至  [ATL_Tools_pypi 【GitHub Repo】](https://github.com/AI-Tianlong/ATL_Tools_pypi).
## 1. 文件夹/数据绝对路径搜索工具
加载方式:

```python
from ATL_Tools import mkdir_or_exist, find_data_list
```

## 2. 遥感图像处理工具:
加载方式:
```python
from ATL_Tools.ATL_gdal import (
    read_img_to_array_with_info, # ✔读取影像为数组并返回信息
    read_img_to_array,  # ✔读取影像为数组
    save_ds_to_tif,     # ✔将GDAL dataset数据格式写入tif保存
    save_array_to_tif,  # 将数组格式写入tif保存
    read_img_get_geo,   # ✔计算影像角点的地理坐标或投影坐标
    ds_get_img_geo,     # 读取dataset格式,计算影像角点的地理坐标或投影坐标
    pix_to_geo,         # 计算影像某一像素点的地理坐标或投影坐标
    geo_to_pix,         # 根据GDAL的仿射变换参数模型将给定的投影或地理坐标转为影像图上坐标(行列号)
    Mosaic_all_imgs,    # ✔将指定路径文件夹下的tif影像全部镶嵌到一张影像上
    Mosaic_2img_to_one, # 将两幅影像镶嵌至同一幅影像
    raster_overlap,     # 两个栅格数据集取重叠区或求交集(仅测试方形影像)
    crop_tif_with_json_zero, # ✔将带有坐标的图像按照json矢量进行裁切,无数据区域为0
    crop_tif_with_json_nan,  # ✔将带有坐标的图像按照json矢量进行裁切,无数据区域为nan
    Merge_multi_json,   # ✔将多个小的json合并为一个大的json,
    resample_image      # ✔使用GDAL对图像进行重采样
                        )
```
## 3. 使用方法

### 3.1 ATL_path 文件夹工具

使用程序示例:  
1. 创建文件夹
    ```python
    from ATL_Tools import mkdir_or_exist, find_data_list
    #创建文件夹
    mkdir_or_exist('新文件夹名称')
    #获取文件夹内所有后缀为.jpg的文件绝对路径
    ```
2. 获取文件夹内所有后缀为 `.jpg` 的文件绝对路径
    ```python
    img_lists = find_data_list(img_root_path='数据集文件夹路径', suffix ='.jpg')
    ```
### 3.2 ATL_gdal 遥感图像处理工具
使用程序示例:
1. 根据矢量批量裁切影像
    ```python
    from ATL_Tools import mkdir_or_exist, find_data_list
    from ATL_Tools.ATL_gdal import crop_tif_with_json_nan
    from tqdm import tqdm
    import os 

    img_path_all = '../推理出的结果_24类_RGB/'
    output_path_all = '../推理出的结果_24类_RGB_crop'
    json_path_all = '../要推理的json/'
    mkdir_or_exist(output_path_all)
    img_list = find_data_list(img_path_all, suffix='.tif')


    for img_path in tqdm(img_list, colour='Green'):

        img_output_path = os.path.join(output_path_all, os.path.basename(img_path))
        json_path = os.path.join(json_path_all, os.path.basename(img_path).split('_')[-1].replace('.tif', '.json'))
        print(f'正在裁切: {img_output_path},json: {json_path}')
        crop_tif_with_json_nan(img_path, img_output_path, json_path)
    ```

## 4. 版本更新日志
- 2023-12-06 v1.0.2 修复README中显示问题。
- 2023-12-06 v1.0.3 修改项目名称为ATL_Tools。
- 2024-04-03 v1.0.6 增加ATL_gdal模块,用于处理遥感影像。
- 2024-04-09 v1.0.7 修复ATL_gdal模块中对于ATL_path的引用,`__init__.py` 注释掉`from ATL_gdal import *`, 可不安装gdal使用ATL_Tools
- 2024-04-16 v1.0.8 修复 `ValueError: cannot convert float NaN to integer` in ATL_gdal Line 371
- 2024-04-16 v1.0.9 修复 修复`Mosaic_all_images()`对于mosaic RGB uint8标签的支持,优化`find_data_list()`函数显示,优化`_init_.py`, 优化`Readme.md`显示
- 2024-04-16 v1.1.0 pypi页面增加`ATL_Tools`Github贡献地址。
- 2024-04-16 v1.1.1 `crop_tif_with_json_nan()`增加可选参数`add_alpha_chan: bool`控制是否为RGB标签增加 alpha 通道
- 2024-04-16 v1.1.2 修复 ATL_gdal Line 397 变量使用错误
- 2024-04-18 v1.1.3 修复 ATL_gdal Mosaic中对float32图像背景设置为nan的支持

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "ATL-Tools",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "ATL_Tools, GDAL, AI-Tianlong, Chinese",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/da/4e/929b4bc4da7e1f552903b86133b505c4671357f1612b8b6366667e858f36/atl_tools-1.1.3.tar.gz",
    "platform": null,
    "description": "# ATL_Tools \u4f7f\u7528\u6307\u5357\n## 0. \u7b80\u4ecb\nATL_Tools \u662f\u4e00\u4e2a\u7531 [AI-Tianlong\u3010GitHub\u3011](https://github.com/AI-Tianlong)\u5f00\u53d1\u7684\u5de5\u5177\u96c6\u5408\uff0c\u5305\u542b\u4e00\u4e9b\u4fbf\u5229\u7684\u5c0f\u5de5\u5177\u3002\n\u5982\u679c\u60a8\u6709\u65b0\u7684\u6a21\u5757\u6dfb\u52a0\uff0c\u6216\u8005\u5bf9\u73b0\u6709\u6a21\u5757\u6709\u6539\u8fdb\u610f\u89c1\uff0c\u6b22\u8fce\u63d0\u4ea4 PR \u81f3  [ATL_Tools_pypi \u3010GitHub Repo\u3011](https://github.com/AI-Tianlong/ATL_Tools_pypi).\n## 1. \u6587\u4ef6\u5939/\u6570\u636e\u7edd\u5bf9\u8def\u5f84\u641c\u7d22\u5de5\u5177\n\u52a0\u8f7d\u65b9\u5f0f:\n\n```python\nfrom ATL_Tools import mkdir_or_exist, find_data_list\n```\n\n## 2. \u9065\u611f\u56fe\u50cf\u5904\u7406\u5de5\u5177:\n\u52a0\u8f7d\u65b9\u5f0f:\n```python\nfrom ATL_Tools.ATL_gdal import (\n    read_img_to_array_with_info, # \u2714\u8bfb\u53d6\u5f71\u50cf\u4e3a\u6570\u7ec4\u5e76\u8fd4\u56de\u4fe1\u606f\n    read_img_to_array,  # \u2714\u8bfb\u53d6\u5f71\u50cf\u4e3a\u6570\u7ec4\n    save_ds_to_tif,     # \u2714\u5c06GDAL dataset\u6570\u636e\u683c\u5f0f\u5199\u5165tif\u4fdd\u5b58\n    save_array_to_tif,  # \u5c06\u6570\u7ec4\u683c\u5f0f\u5199\u5165tif\u4fdd\u5b58\n    read_img_get_geo,   # \u2714\u8ba1\u7b97\u5f71\u50cf\u89d2\u70b9\u7684\u5730\u7406\u5750\u6807\u6216\u6295\u5f71\u5750\u6807\n    ds_get_img_geo,     # \u8bfb\u53d6dataset\u683c\u5f0f\uff0c\u8ba1\u7b97\u5f71\u50cf\u89d2\u70b9\u7684\u5730\u7406\u5750\u6807\u6216\u6295\u5f71\u5750\u6807\n    pix_to_geo,         # \u8ba1\u7b97\u5f71\u50cf\u67d0\u4e00\u50cf\u7d20\u70b9\u7684\u5730\u7406\u5750\u6807\u6216\u6295\u5f71\u5750\u6807\n    geo_to_pix,         # \u6839\u636eGDAL\u7684\u4eff\u5c04\u53d8\u6362\u53c2\u6570\u6a21\u578b\u5c06\u7ed9\u5b9a\u7684\u6295\u5f71\u6216\u5730\u7406\u5750\u6807\u8f6c\u4e3a\u5f71\u50cf\u56fe\u4e0a\u5750\u6807\uff08\u884c\u5217\u53f7\uff09\n    Mosaic_all_imgs,    # \u2714\u5c06\u6307\u5b9a\u8def\u5f84\u6587\u4ef6\u5939\u4e0b\u7684tif\u5f71\u50cf\u5168\u90e8\u9576\u5d4c\u5230\u4e00\u5f20\u5f71\u50cf\u4e0a\n    Mosaic_2img_to_one, # \u5c06\u4e24\u5e45\u5f71\u50cf\u9576\u5d4c\u81f3\u540c\u4e00\u5e45\u5f71\u50cf\n    raster_overlap,     # \u4e24\u4e2a\u6805\u683c\u6570\u636e\u96c6\u53d6\u91cd\u53e0\u533a\u6216\u6c42\u4ea4\u96c6\uff08\u4ec5\u6d4b\u8bd5\u65b9\u5f62\u5f71\u50cf\uff09\n    crop_tif_with_json_zero, # \u2714\u5c06\u5e26\u6709\u5750\u6807\u7684\u56fe\u50cf\u6309\u7167json\u77e2\u91cf\u8fdb\u884c\u88c1\u5207,\u65e0\u6570\u636e\u533a\u57df\u4e3a0\n    crop_tif_with_json_nan,  # \u2714\u5c06\u5e26\u6709\u5750\u6807\u7684\u56fe\u50cf\u6309\u7167json\u77e2\u91cf\u8fdb\u884c\u88c1\u5207,\u65e0\u6570\u636e\u533a\u57df\u4e3anan\n    Merge_multi_json,   # \u2714\u5c06\u591a\u4e2a\u5c0f\u7684json\u5408\u5e76\u4e3a\u4e00\u4e2a\u5927\u7684json,\n    resample_image      # \u2714\u4f7f\u7528GDAL\u5bf9\u56fe\u50cf\u8fdb\u884c\u91cd\u91c7\u6837\n                        )\n```\n## 3. \u4f7f\u7528\u65b9\u6cd5\n\n### 3.1 ATL_path \u6587\u4ef6\u5939\u5de5\u5177\n\n\u4f7f\u7528\u7a0b\u5e8f\u793a\u4f8b:  \n1. \u521b\u5efa\u6587\u4ef6\u5939\n    ```python\n    from ATL_Tools import mkdir_or_exist, find_data_list\n    #\u521b\u5efa\u6587\u4ef6\u5939\n    mkdir_or_exist('\u65b0\u6587\u4ef6\u5939\u540d\u79f0')\n    #\u83b7\u53d6\u6587\u4ef6\u5939\u5185\u6240\u6709\u540e\u7f00\u4e3a.jpg\u7684\u6587\u4ef6\u7edd\u5bf9\u8def\u5f84\n    ```\n2. \u83b7\u53d6\u6587\u4ef6\u5939\u5185\u6240\u6709\u540e\u7f00\u4e3a `.jpg` \u7684\u6587\u4ef6\u7edd\u5bf9\u8def\u5f84\n    ```python\n    img_lists = find_data_list(img_root_path='\u6570\u636e\u96c6\u6587\u4ef6\u5939\u8def\u5f84', suffix ='.jpg')\n    ```\n### 3.2 ATL_gdal \u9065\u611f\u56fe\u50cf\u5904\u7406\u5de5\u5177\n\u4f7f\u7528\u7a0b\u5e8f\u793a\u4f8b\uff1a\n1. \u6839\u636e\u77e2\u91cf\u6279\u91cf\u88c1\u5207\u5f71\u50cf\n    ```python\n    from ATL_Tools import mkdir_or_exist, find_data_list\n    from ATL_Tools.ATL_gdal import crop_tif_with_json_nan\n    from tqdm import tqdm\n    import os \n\n    img_path_all = '../\u63a8\u7406\u51fa\u7684\u7ed3\u679c_24\u7c7b_RGB/'\n    output_path_all = '../\u63a8\u7406\u51fa\u7684\u7ed3\u679c_24\u7c7b_RGB_crop'\n    json_path_all = '../\u8981\u63a8\u7406\u7684json/'\n    mkdir_or_exist(output_path_all)\n    img_list = find_data_list(img_path_all, suffix='.tif')\n\n\n    for img_path in tqdm(img_list, colour='Green'):\n\n        img_output_path = os.path.join(output_path_all, os.path.basename(img_path))\n        json_path = os.path.join(json_path_all, os.path.basename(img_path).split('_')[-1].replace('.tif', '.json'))\n        print(f'\u6b63\u5728\u88c1\u5207: {img_output_path},json: {json_path}')\n        crop_tif_with_json_nan(img_path, img_output_path, json_path)\n    ```\n\n## 4. \u7248\u672c\u66f4\u65b0\u65e5\u5fd7\n- 2023-12-06 v1.0.2 \u4fee\u590dREADME\u4e2d\u663e\u793a\u95ee\u9898\u3002\n- 2023-12-06 v1.0.3 \u4fee\u6539\u9879\u76ee\u540d\u79f0\u4e3aATL_Tools\u3002\n- 2024-04-03 v1.0.6 \u589e\u52a0ATL_gdal\u6a21\u5757\uff0c\u7528\u4e8e\u5904\u7406\u9065\u611f\u5f71\u50cf\u3002\n- 2024-04-09 v1.0.7 \u4fee\u590dATL_gdal\u6a21\u5757\u4e2d\u5bf9\u4e8eATL_path\u7684\u5f15\u7528\uff0c`__init__.py` \u6ce8\u91ca\u6389`from ATL_gdal import *`, \u53ef\u4e0d\u5b89\u88c5gdal\u4f7f\u7528ATL_Tools\n- 2024-04-16 v1.0.8 \u4fee\u590d `ValueError: cannot convert float NaN to integer` in ATL_gdal Line 371\n- 2024-04-16 v1.0.9 \u4fee\u590d \u4fee\u590d`Mosaic_all_images()`\u5bf9\u4e8emosaic RGB uint8\u6807\u7b7e\u7684\u652f\u6301\uff0c\u4f18\u5316`find_data_list()`\u51fd\u6570\u663e\u793a\uff0c\u4f18\u5316`_init_.py`, \u4f18\u5316`Readme.md`\u663e\u793a\n- 2024-04-16 v1.1.0 pypi\u9875\u9762\u589e\u52a0`ATL_Tools`Github\u8d21\u732e\u5730\u5740\u3002\n- 2024-04-16 v1.1.1 `crop_tif_with_json_nan()`\u589e\u52a0\u53ef\u9009\u53c2\u6570`add_alpha_chan: bool`\u63a7\u5236\u662f\u5426\u4e3aRGB\u6807\u7b7e\u589e\u52a0 alpha \u901a\u9053\n- 2024-04-16 v1.1.2 \u4fee\u590d ATL_gdal Line 397 \u53d8\u91cf\u4f7f\u7528\u9519\u8bef\n- 2024-04-18 v1.1.3 \u4fee\u590d ATL_gdal Mosaic\u4e2d\u5bf9float32\u56fe\u50cf\u80cc\u666f\u8bbe\u7f6e\u4e3anan\u7684\u652f\u6301\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "AI-Tianlong\u7684Tools\u6253\u5305\uff0c\u5f00\u7bb1\u5373\u7528, \u5305\u542bATL_path\u548cATL_gdal,\u53ef\u7528\u4e8e\u6587\u4ef6\u5939\u521b\u5efa\u3001\u6587\u4ef6\u641c\u7d22\u3001\u9065\u611f\u56fe\u50cf\u5904\u7406",
    "version": "1.1.3",
    "project_urls": null,
    "split_keywords": [
        "atl_tools",
        " gdal",
        " ai-tianlong",
        " chinese"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8fa07f755a570bf3ac4b484d327c6e952ab87b891e4fcbbb24de4ffb9a9ba1eb",
                "md5": "8a64a4eb7a2cd57efeb0eb061482b3cb",
                "sha256": "ed8ccfe2057d3f389c203b8afc5f29166efc372f86865aad1f9a1a56c4dcfd3d"
            },
            "downloads": -1,
            "filename": "ATL_Tools-1.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8a64a4eb7a2cd57efeb0eb061482b3cb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 14273,
            "upload_time": "2024-04-18T10:36:02",
            "upload_time_iso_8601": "2024-04-18T10:36:02.294750Z",
            "url": "https://files.pythonhosted.org/packages/8f/a0/7f755a570bf3ac4b484d327c6e952ab87b891e4fcbbb24de4ffb9a9ba1eb/ATL_Tools-1.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "da4e929b4bc4da7e1f552903b86133b505c4671357f1612b8b6366667e858f36",
                "md5": "b28b5934cd3337d61c5bbfcb93486eca",
                "sha256": "e3f12ffbc7c6b93c0a99553715afda2f0d7e8e63287b2f329c1a567da5b30d3a"
            },
            "downloads": -1,
            "filename": "atl_tools-1.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "b28b5934cd3337d61c5bbfcb93486eca",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 12156,
            "upload_time": "2024-04-18T10:36:05",
            "upload_time_iso_8601": "2024-04-18T10:36:05.024530Z",
            "url": "https://files.pythonhosted.org/packages/da/4e/929b4bc4da7e1f552903b86133b505c4671357f1612b8b6366667e858f36/atl_tools-1.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-18 10:36:05",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "atl-tools"
}
        
Elapsed time: 0.24588s