A util for converting netcdf datasets and TIFF images to and from each other
Project description
TIFF-NC 转换工具
本工具提供了将 NetCDF 文件与多波段 TIFF 文件相互转换的功能,适用于气象、地理等领域的数据处理。
功能概述
-
NetCDF 转 TIFF (
nc_to_tiffs)
将 NetCDF 文件转换为多波段 TIFF 文件,支持按时间维度切片并输出多个 TIFF 文件。 -
TIFF 转 NetCDF (
tiffs_to_nc)
将多波段 TIFF 文件合并为一个 NetCDF 文件,支持按时间维度重新组织数据。
函数说明
1. nc_to_tiffs
将 NetCDF 文件转换为多波段 TIFF 文件。
参数
nc_file(str): 输入的 NetCDF 文件路径。tiffs_dir(str): 输出 TIFF 文件的保存目录。chunks(int | dict, 可选): 分块大小,默认为512。var_name(str | list[str]): 变量名或变量名列表,每个变量对应一个波段,默认为"variable"。time_dim(str, 可选): 时间维度名称,默认为"valid_time"。shapefile(str | None, 可选): 边界文件路径,默认为None。crs(str, 可选): 坐标参考系统,默认为"EPSG:4326"。time_format(str, 可选): 时间格式,默认为"%Y%m%d"。workers(int, 可选): 进程数,默认为4。
示例
nc_to_tiffs(
nc_file="input.nc",
tiffs_dir="output_dir",
chunks={"valid_time": -1, "latitude": 512, "longitude": 512},
var_name=["variable1", "variable2"],
time_dim="valid_time",
shapefile="boundary.shp",
crs="EPSG:4326",
)
注意
- 该函数将输入的 NetCDF 文件转换为多波段 TIFF 文件,并支持按时间维度进行切片和输出多个 TIFF 文件。
- 该函数支持按时间维度进行切片和输出多个 TIFF 文件,并支持边界裁剪和坐标转换。
- 该函数支持边界裁剪和坐标转换,以适应不同场景的需求。
- 该函数支持多进程并行处理,以加速处理速度。
- chunks dict 的键值对表示每个维度的名称和分块大小。eg:
{"valid_time": -1, "latitude": 512, "longitude": 512}如果不指定分块大小,则设置为-1,表示该维度不进行分块。
2. tiffs_to_nc
将多波段 TIFF 文件合并为一个 NetCDF 文件。
参数
tiffs_dir(str): 输入 TIFF 文件的目录路径。nc_file(str): 输出的 NetCDF 文件路径。var_name(str | list[str]): 变量名或变量名列表,每个变量对应一个波段。time_dim(str, 可选): 时间维度名称,默认为"valid_time"。chunks(dict, 可选): 分块大小,默认为None。time_format(str, 可选): 时间格式,默认为"%Y%m%d"。workers(int, 可选): 工作进程数,默认为4。
示例
tiffs_to_nc(
tiffs_dir="input_dir",
nc_file="output.nc",
var_name=["variable1", "variable2"],
time_dim="valid_time",
chunks={"valid_time": -1, "latitude": 512, "longitude": 512},
time_format="%Y%m%d",
workers=4,
)
注意
- 该函数将输入的多波段 TIFF 文件合并为一个 NetCDF 文件,并支持按时间维度进行重新组织数据。
- 该函数支持按时间维度进行重新组织数据,并支持多进程并行处理,以加速处理速度。
- chunks dict 的键值对表示每个维度的名称和分块大小。eg:
{"valid_time": -1, "latitude": 512, "longitude": 512}如果不指定分块大小,则设置为-1,表示该维度不进行分块。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tiff_nc-0.3.0.tar.gz.
File metadata
- Download URL: tiff_nc-0.3.0.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cb30d2b5f907df4ca5795342fd74854e28a7fb5424bc8f0d6b5e995a1541cfd
|
|
| MD5 |
76c211fb2d56b5e46df6f93a4ec7791e
|
|
| BLAKE2b-256 |
c329b597e23eb1b73d67be177541f5cbe493bcc50022cae962221a696e46bb30
|
File details
Details for the file tiff_nc-0.3.0-py3-none-any.whl.
File metadata
- Download URL: tiff_nc-0.3.0-py3-none-any.whl
- Upload date:
- Size: 4.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f58fbc96b376015555e17118f1efc12e546f7c138b6000df51e2d9faf0609d6a
|
|
| MD5 |
944fe398b61d1c0dd566f2559fe996e5
|
|
| BLAKE2b-256 |
c15a0b0a9ec539eab850db63c83469084998376f2bd3305827126619a2bac8ce
|