Hi Rafat,
I see that you want to synchronize the .tif files to a specific size, [5977 x 2284], and set the padding cells to a default value of -9999999800000.
You can use the following process to synchronize multiple files to the desired dimensions:
- Iterate through each .tif file, reading them using the 'readgeoraster' function and storing the resulting array and spatial referencing information in variables A and R, respectively.
- Generate a matrix of the desired size, with each cell set to -9999999800000.
- Calculate the position to place the original image in the center and insert it into the resized image.
- Adjust the 'RasterSize' of the spatial referencing object 'R' to match the desired size.
- Utilize the 'geotiffwrite' function to write the resized image back to the original file.
You can follow the below workaround to execute the steps:
desired_size = [5977, 2284];
filling_value = -9999999800000;
[A,R] = readgeoraster(files(i).name);
resized_image = filling_value * ones(desired_size);
row_start = floor((desired_size(1) - rows) / 2) + 1;
col_start = floor((desired_size(2) - cols) / 2) + 1;
resized_image(row_start:(row_start+rows-1), col_start:(col_start+cols-1)) = A;
R.RasterSize = desired_size;
geotiffwrite(files(i).name, resized_image, R);
Also, you can use the 'imshow' function to visualize the original image, i.e., A and the resized_image. In the case of the resized_image, it may be necessary to zoom in to observe the details due to the padding around the original image.
Please refer to the following documentation to know more about the 'readgeoraster', 'geotiffwrite' and 'imshow' functions:
I hope it helps.
Best Regards,
Shivam