I am trying to batch georeference a set of raster images using the GDAL function in python. For this, I georeferenced a raster image manually using QGIS and extracted the values of GCP as a CSV file. I then used the GCP points from the QGIS as the input and the SRC and CRC ESRI value I used was 102025. For some reason, the output is getting inverted. I tried to change the projection, modified pixel values and still, the output image is inverted.
Please find the attached code and the set of Input and Output Images.
# Skipping the input CSV extraction of the program (I did it using pandas data frame) #list of GCP points gcp_list= for index, rows in modified_df.iterrows(): gcps = gdal.GCP(rows.mapX, rows.mapY, 1, rows.pixelX, rows.pixelY ) gcp_list.append(gcps) # Set spatial reference: sr = osr.SpatialReference() # Projection- taken from the website of ESRI 102025 sr.ImportFromProj4("+proj=aea +lat_1=15 +lat_2=65 +lat_0=30 +lon_0=95 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m no_defs") # Final Projection ds = gdal.Open( output_fn, gdal.GA_Update ) wkt = ds.GetProjection() gcpcount = ds.GetGCPCount( ) #Inversion is happening here ds.SetGCPs( gcp_list, wkt ) #Clear the output file if it is opened anywhere else ds=None
Output Image using GDAL
Output of QGIS
Projection of the GDAL output in OSM
The value 1200 was added to all the pixel values of the Y coordinate because the pixel values were negative.
Georeferenced using ESRI: 102025 both in QGIS and GDAL.