Skip to main content

A Python GeoTiff kit based on GDAL

Project description

geotifflib

基于GDAL,对GeoTiff文件进行读写等操作。 GeoTiffLib primarily offers a set of utility functions for reading, saving, and processing GeoTIFF image files.

安装

由于使用pip安装GDAL报错,因此安装此包之前需要使用conda安装GDAL

conda install GDAL

安装GDAL完成之后再安装本包:

pip install geotifflib

使用

主要包含了读、写两类函数。

read()

根据文件路径读取GeoTiff数据、地理变换和投影。

输入:

  1. 文件路径(Path or str)

返回:

  1. tiff的数据矩阵(np.array):shape = [波段,宽,长]

read_geo()

根据文件路径读取GeoTiff数据形状、地理变换和投影。

输入:

  1. 文件路径(Path or str)

返回:

  1. tiff的数据矩阵(np.array):shape = [波段,宽,长]
  2. geotransform: tuple
  3. projection: str

save()

保存GeoTiff数据、地理变换和投影。

输入:

  1. 保存路径(Path or str)
  2. tiff的数据矩阵(np.array):shape = [波段,宽,长]
  3. geotransform: tuple, tif file geotransform
  4. projection: str, tif file projection
  5. output dtype: gdal.GDT_Float32, tif file data type

save_array()

保存GeoTiff数据。

输入:

  1. 保存路径(Path or str)
  2. tiff的数据矩阵(np.array):shape = [波段,宽,长]
  3. output dtype: gdal.GDT_Float32, tif file data type

hsi_to_rgb()

将光谱数据转化到RGB(做了$\gamma$矫正和归一化)

输入:

  1. 光谱数据(np.ndarray):The hyperspectral image data, default shape is [bands, width, height].
  2. 红光波段索引(int):The index of the red band.
  3. 绿光波段索引(int):The index of the green band.
  4. 蓝光波段索引(int):The index of the blue band.

返回:

  1. The RGB image data, shape is [width, height, 3(r, g, b)].

merge()

合并多个GeoTiff

输入:

  1. 输入的tif图像路径列表(list[Path, Path...])
  2. 输出的tif图像路径(Path)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

geotifflib-0.0.6.tar.gz (10.1 kB view details)

Uploaded Source

File details

Details for the file geotifflib-0.0.6.tar.gz.

File metadata

  • Download URL: geotifflib-0.0.6.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.2

File hashes

Hashes for geotifflib-0.0.6.tar.gz
Algorithm Hash digest
SHA256 de3474b267acb2d3f52b85408d9bef2192b2accda183b02b16ebacc3ee6337a8
MD5 2a2ea27fb5208fac1cb3d4679b9e198f
BLAKE2b-256 8eebf071193139290c00b3eec78b34242c6d0bc8e0aaace89d7212f8511e97d9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page