坐标系转换 tif_WGS84 to polar3413

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)
            )
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值