30 Мар

Space data GeoTiff rescaling (Matlab)

sat_img1Simple but working algorithm of SRTM image downscaling (recalculating in less resolution) and saving georeferenced. Sometimes space data should be downscaled for generalization purposes.

Algorithm beneath opens geotiff with mapping toolbox of Matlab, reads datum reference, downscales image, then writes on a disk. Though, geotiff write demands explicit projection zone pointing.

  1. clear;close all;
  2. %read geotiff
  3. filename='mygeotiff.tiff';
  4. imscale=0.5; %scaling factor
  5. % Appends the file path and the file name together.
  6. [img, Reference] = geotiffread(filename);
  7. img_lres=imresize(img,imscale);
  8. R = maprasterref;
  9. R.XWorldLimits=Reference.XWorldLimits;
  10. R.YWorldLimits=Reference.YWorldLimits;
  11. R.RasterSize=size(img_lres);
  12. R.ColumnsStartFrom=Reference.ColumnsStartFrom;
  13. R.RowsStartFrom=Reference.RowsStartFrom;
  14. filename = 'resampled_L8_mnog_all_07.tif';
  15. geotiffwrite(filename,img_lres,R,'CoordRefSysCode','EPSG:32654'); %'EPSG:32653'); - last 2 digits - zone number
  16. imshow(img_lres)


Добавить комментарий