I am currently using GDAL 2.1.0 in a Python script to reproject a geotiff with a given pixel size into an other geotiff with the same projection, but with a different pixel size. To do so, I use the following GDAL function:

     gdal.ReprojectImage(in_dataset, out_dataset, in_srs.ExportToWkt(),    
                         out_srs.ExportToWkt(), gdalconst.GRA_Average)

Is there any way I can control how the resampling option provided by gdalconst deals with the edges of my image?

In this case, I end up with the new image that has the 2 first rows, the last row, the first column and the last column with a value of 0 (i.e. around the edge of my reprojected image). And this can be more depending on the resampling method. Below, the first picture is the original image on a Google Map in a GIS and the second is the reprojected image showing the border.

enter image description hereReprojected

For the moment, I convert the edge pixels to NaNs through indexing:

myarray = np.pad(myarray[2:-2, 2:-2], ((2,2),(2,2)), mode='constant',

but I feel this isn't the best way to deal with it and am hoping there is an in-built solution (as it is the case for other libraries such as astropy's convolute).



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.