Created
November 5, 2020 02:25
-
-
Save underchemist/8e57d222e472b8a5c909843f80a7a176 to your computer and use it in GitHub Desktop.
rasterio warp with rpcs example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
RPC_DEM_SRS only used in GDAL >= 3.2.0, otherwise ignored | |
""" | |
import rasterio | |
import rasterio.warp | |
from rasterio import logging | |
logging.basicConfig(filename='rasterio.log', level=logging.DEBUG) | |
with rasterio.Env(CPL_DEBUG='ON', PROJ_DEBUG='3') as env: # maybe still set CPL_DEBUG and PROJ_DEBUG as env var? | |
with rasterio.open('rpc.tif') as src: | |
arr, transform = rasterio.warp.reproject( | |
rasterio.band(src, src.indexes), | |
src_crs="EPSG:4326", | |
rpcs=src.rpcs, | |
dst_crs="EPSG:4326", | |
RPC_DEM="vancouver-dem-downsampled.tif", | |
RPC_DEM_SRS="EPSG:4326+5773" | |
) | |
with rasterio.open('rpc-warped-rasterio.tif', mode='w', transform=transform, crs="EPSG:4326", dtype=src.dtypes[0], count=arr.shape[0], height=arr.shape[1], width=arr.shape[2]) as dst: | |
dst.write(arr, src.indexes) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment