GDAL second order polynomial fails in Python but first order and thin plate spline work fine

gdalgdalwarppythonqgis-3

I have Python code that will automatically georeference drone images regardless of overlap and without SfM software. The code runs without error when I set my transformation type to a first order polynomial but I am unhappy with the georeferencing. I can alter my code to use a thin plate spline transformation and this also runs without error. I would like to test the output of a second order polynomial. When I change the arguments to gdal_warp to apply a second order polynomial I get the following error:

Error Info:
Failed to compute GCP transform: Transform is not solvable

Here is the relevant code for the working TPS transformation:

kwargs = {'format': 'GTiff', 'tps': True, 'dstSRS':'EPSG:4326'}

and here is the relevant code for the working first order polynomial transformation:

kwargs = {'format': 'GTiff', 'polynomialOrder':1,'dstSRS':'EPSG:4326'}
   

And here is the relevant code for the failed second order transformation:

kwargs = {'format': 'GTiff', 'polynomialOrder':2,'dstSRS':'EPSG:4326'}
    

If I try a second order transformation in QGIS with less than 6 GCPs QGIS complains and returns an error message that I need 6 GCPs for this transformation. I am feeding 6 GCP into GDAL. See this link for some past trouble shooting issues and details on the project.

Why is GDAL/Python not allowing me to do a second order polynomial transformation?

Best Answer

As per the suggestion from @user30184 feeding 8 gcps into the process solved the issue and allowed me to do a second order transformation.