Unclear how to implement image alignment based on GCPs

mmweene15@...
 

I am trying to replicated the gdal functionality for performing image alignment based on GCPs. The equivalent gdal commands are the following:

`gdal_translate -of GTiff -gcp GCP1 -gcp GCP2... src_raster dst_raster`
`gdalwarp -s_srs S_SRS -t_srs T_SRS -tps dst_raster dst_raster2`

This would create a new raster, `dst_raster2` that has been reprojected according to the specified GCPs. It is unclear, based on the documentation, how to achieve this using the rasterio.warp module. I have tried using the rasterio.warp.reproject function to no avail. I've included a snippet of code below. The resulting image does not match the image produced by gdal. Any guidance would be appreciated. Note that the variables are descriptively named.

with rasterio.open(target_image_path, 'r') as f:
target_profile = f.profile
target_image = image_tools.rasterio_read_bands(f)
print(target_profile)

destination = np.empty(target_image.shape, dtype=target_profile['dtype'])
resolution = (target_profile['transform'].a, target_profile['transform'].e)
transform, width, height = rasterio_warp.calculate_default_transform(src_crs,
dst_crs,
gcps=gcps,
resolution=resolution,
height=target_profile['height'],
width=target_profile['width'])

rasterio_warp.reproject(source=target_image,
destination=destination,
gcps=gcps,
src_crs=src_crs,
dst_crs=src_crs,
# src_transform=target_profile['transform'],
dst_transform=target_profile['transform'],
resampling=getattr(enums.Resampling, resampling_method),
num_threads=num_threads)

Join main@rasterio.groups.io to automatically receive all group messages.