python 读取geotiff_如何在python中编写/创建GeoTIFF RGB图像文件?

本文介绍如何使用Python的gdal库从numpy数组创建GeoTIFF RGB图像文件。作者遇到的问题是生成的GeoTIFF文件过大且显示为黑色,解决方法是将数据类型更改为GDT_Byte。示例代码展示了创建RGB图像并设置地理变换的过程。
摘要由CSDN通过智能技术生成

I have 5 numpy arrays of shape nx, ny

lons.shape = (nx,ny)

lats.shape = (nx,ny)

reds.shape = (nx,ny)

greens.shape = (nx,ny)

blues.shape = (nx,ny)

The reds, greens and blues arrays contain values that range from 0–255 and the lat/lon arrays are latitude/longitude pixel coordinates.

My question is how do I write this data to a geotiff?

I ultimately want to plot the image using basemap.

Here is the code I have so far, however I get a huge GeoTIFF file (~500MB) and it comes up blank (just a black image). Also note that nx, ny = 8120, 5416.

from osgeo import gdal

from osgeo import osr

import numpy as np

import h5py

import os

os.environ['GDAL_DATA'] = "/Users/andyprata/Library/Enthought/Canopy_64bit/User/share/gdal"

# read in d

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值