- Use “getframe” to capture the current figure window as a frame
- Use “maprefcells” to create a spatial referencing object that defines how the image data maps to the geographic coordinates
- Use “geotiffwrite” to write the captured image data to a GeoTIFF file
How can I export geoplots to a GeoTIFF file in MATLAB R2024a?
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
MathWorks Support Team
il 13 Mar 2025
Risposto: MathWorks Support Team
il 14 Mar 2025
I am using MATLAB R2024a and have geographical data plotted using functions like "geoplot". I want to export the output to a GeoTIFF file. How can I do this?
Risposta accettata
MathWorks Support Team
il 13 Mar 2025
MATLAB currently does not have a function to directly export plots created using "geoplot" or other related functions to a GeoTIFF file.
However, the following workaround can be used to write to a GeoTIFF file after plotting the data with "geoplot" or other similar functions:
Please refer to the following sample code that demonstrates the proposed workaround:
%Define coordinates
latitudes = [34.0522, 36.7783, 40.7128];
longitudes = [-118.2437, -119.4179, -74.0060];
%Create geographic plots
figure;
geoplot(latitudes, longitudes, 'ro-', 'LineWidth', 2);
geobasemap('streets');
%Capture the Plot as an Image:
F = getframe;
cdata = F.cdata;
%Get geographic limits
[latlim, lonlim] = geolimits;
%Define Projection and Convert Limits:
p = projcrs(3857); %Projection coordinate system for web mercator (EPSG:3857)
[xlimits, ylimits] = projfwd(p, latlim, lonlim); %Project latitude and longitude limits to x and y limits
% Create Spatial Referencing Object (to rasterize the data):
R = maprefcells(xlimits, ylimits, size(cdata,[1 2]),"ColumnsStartFrom","north");
% Write to a GeoTIFF file
geotiffwrite("geoplot3.tif", cdata, R, "CoordRefSysCode", "EPSG:3857")
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Geographic Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!