对于第二个栅格,我有以下信息: enter image description here
我的目标是使用光栅2的空间信息重新投影光栅#1。 我尝试使用rasterio,结果显示以下空间参考:Krassovsky_1942_Transverse_Mercator,并且基准未知。使用以下代码后获得此结果:
import numpy as np
import rasterio
from rasterio.warp import calculate_default_transform, reproject, Resampling
#----------------------------------------------------------------------------- #
# OPENING IMAGE WITH THE CORRECT SPATIAL REFERENCE
#-----------------------------------------------------------------------------#
with rasterio.open(r"C:\Users\Roger\Documents\git\ArcpyRecipes\Test_rasterio\test_albania\raster\AL_020m_nat_buffer100m.tif") as proj:
dst_crs = proj.crs
print dst_crs
transform_proj, width_proj, height_proj = calculate
#-----------------------------------------------------------------------------#
# OPENING IMAGE WITH TO BE REPROJECTED
#-----------------------------------------------------------------------------#
with rasterio.open(r"C:\Users\Roger\Documents\git\ArcpyRecipes\Test_rasterio\test_albania\results\umprojected\ALB_adm0.tif") as src:
transform, width, height = calculate_default_transform(
src.crs, dst_crs, src.width, src.height, *src.bounds)
kwargs = src.meta.copy()
kwargs.update({
"crs": dst_crs,
"transform": transform,
"width": width,
"height": height
})
#---------------------------------------------------------------------------
# CREATING THE OUTPUT IMAGE
#---------------------------------------------------------------------------
with rasterio.open(r"C:\Users\Roger\Documents\git\ArcpyRecipes\Test_rasterio\test_albania\results\projected/Albita_projected_2.tif", "w", **kwargs) as dst:
for i in range(1, src.count + 1):
reproject(
source = rasterio.band(src, i),
destination=rasterio.band(dst, i),
src_transform = src.transform,
src_crs=src.crs,
dst_transform = transform,
dst_crs = dst_crs,
resampling = Resampling.nearest)
我读到可以使用arcpy.Describe在ArcMap中检索EPGS代码,但我想使用模块rasterio来完成任务。我认为用rasterio打开图像后的选项(dataset.crs)会给我CRS来进行投影,但实际情况并非如此。有人可以帮我这个吗?
非常感谢