如何将GeoTIFF投影到指定区域范围?

时间:2019-01-12 13:23:25

标签: python gdal matplotlib-basemap rasterio

我正在尝试在指定区域显示GeoTIFF文件。我要做的是将多频段GeoTIFF文件投影到指定区域。

我的GeoTIFF是包含欧洲区域3个波段的卫星图像。我想将其投影到中欧地区(经纬度定义)。我一直在尝试使用rasterio解决此问题,但到目前为止我还很不幸。这是执行后得到的:

import georaster
import matplotlib.pyplot as plt
from mpl_toolkits.basemap import Basemap
from matplotlib.pyplot import figure

#define path to geotiff
file = "/home/lubomir/Desktop/Sentinel3_OLCI/RGB/OLCI_201812140859_Natural_Color.tif"

m = Basemap(epsg=3395,llcrnrlat=45,urcrnrlat=55,\
            llcrnrlon=5,urcrnrlon=25,lat_ts=15,resolution='f')

m.drawcoastlines(linewidth=0.5, color='g')
m.fillcontinents(color='beige')
m.drawcountries(linewidth=0.5, color='m')

#load GeoTIFF multiband file
image = georaster.MultiBandRaster(file)

plt.imshow(image.r, extent=image.extent, zorder=10)
plt.savefig('test.tiff')
plt.show()

without_geotiff

如您所见,生成的图像不包含我的GeoTIF。知道如何解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

要利用底图的投影,必须使用

m.imshow(image.r, extent=image.extent, zorder=10)

代替

plt.imshow(image.r, extent=image.extent, zorder=10)

希望有帮助。

相关问题