Georeferencing to UTM coordinates gives an offset
12 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi all,
I have a script to georeference a matrix to UTM coordinates, that can be imported into QGIS or another Geographical Information System (GIS). The script (1) works as intended, although with a slight offset from the true position when I import it. I know the UTM zone is correct, and I know the limits of the georeferencing grid and size are correct because I set this in an earlier script. I've checked the EPSG code with the GIS too.
I also have a similar script (2) for doing the same but in WGS84 Lat-Lon coordinates, which works fine without the offset. Any clues as to what might be causing the offsets in the UTM data, or better ways to do this? Thanks!
UTM Script:
Files = dir('matricies-to-be-georeferenced');
% UTM Zone information for your region
utmZone = '18S'; % Update with the appropriate UTM zone for your location
% UTM coordinates of the limits of the TIFF file
xUTMLimits = [100000 110000]; % Update with the actual UTM limits
yUTMLimits = [2000000 2010000]; % Update with the actual UTM limits
for k = 1:length(Files)
Filename = [Files(k).folder,'/',Files(k).name];
load(Filename);
rasterSize = [1200 2400]; %Change this to your size (size of matrix)
% Create the spatial reference object using UTM coordinates
R = maprefcells(xUTMLimits, yUTMLimits, rasterSize, utmZone);
% Create the output filename
Filename = [Files(k).name(1:end-4),'_hd.tif'];
% Flip the raster data if required (needed for display - to do with
% this specific application.
hd = flipud(hd);
% Write the georeferenced TIFF file using UTM coordinates
geotiffwrite(Filename, hd, R);
end
WGS84 script:
Files = dir('matricies-to-be-georeferenced');
for k = 1:length(Files)
Filename = [Files(k).folder,'/',Files(k).name];
load(Filename)
lonlim = [-91 -90.8];
latlim = [14.4 14.5];
rasterSize = [1200 2400];
R = georefcells(latlim,lonlim,rasterSize);
Filename = [Files(k).name(1:end-4),'_hd.tif'];
hd = flipud(hd);
geotiffwrite(Filename,hd,R);
end
0 Kommentare
Antworten (1)
Balaji
am 8 Sep. 2023
Hi Ben,
I understand that you have an issue while trying to georeference a matrix to UTM coordinates. You are creating a MapCellsReference raster using :
R = maprefcells(xUTMLimits, yUTMLimits, rasterSize, utmZone);
But the syntax to create a MapCellsReference raster is :
R = maprefcells(xlimits,ylimits,rasterSize)
For more information on ‘maprefcells’ please refer to:
Hope this helps!
Thanks
Balaji
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!