I'm trying to reproject a raster dataset using a user-defined projection in Python. I was able to achieve the desired reprojection setting ArcGIS's arcpy.CreateCustomGeoTransformation_management
tool and arcpy.ProjectRaster_management
method.
However, I have difficulties in replicating the exact results using rasterio
or rioxarray
. Can anyone offer guidance on how to achieve this reprojection using these libraries?
I have also tried using the default_transformation in rasterio
https://rasterio.readthedocs.io/en/stable/topics/reproject.html
from pyproj.transformer import Transformer
import pycrs
import rioxarray as rxr
from rasterio.enums import Resampling
prj = pycrs.load.from_file('projection_file.prj')
dst_crs = prj.to_proj4()
ds_crs
'+proj=laea +a=6378137.0 +f=0.0 +pm=0 +x_0=0.0 +y_0=0.0 +lon_0=20.0 +lat_0=5.0 +units=m +axis=enu +no_defs'
rain = rxr.open_rasterio('rain_20011.bil').squeeze()
rain_projected = rain.rio.reproject(dst_crs, resampling=Resampling.nearest)
# how can I include the transformation information in the reprojection?
transform = Transformer.from_crs("EPSG:4326",dst_crs)