from pyproj import CRS
import rasterio
from rasterio.warp import calculate_default_transform, reproject, Resampling
# 方式1:通过EPSG代码定义(推荐)
dst_crs = CRS.from_epsg(3413) # NSIDC北极极地立体投影
# 方式2:自定义参数(中央经线、标准纬线)
dst_crs = CRS.from_proj4("+proj=stere +lat_0=90 +lat_ts=70 +lon_0=0 +x_0=0 +y_0=0 +datum=WGS84 +units=m")
# 输入输出路径
src_path = r"F:\xx.tif"
dst_path = r"F:\ff.tif"
with rasterio.open(src_path) 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
})
# 执行重投影
with rasterio.open(dst_path, '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.bilinear # 双线性插值保持连续性[3,5](@ref)
)
坐标系转换 tif_WGS84 to polar3413
最新推荐文章于 2025-11-24 15:28:47 发布
1454

被折叠的 条评论
为什么被折叠?



