Steve on Image Processing with MATLAB

Image processing concepts, algorithms, and MATLAB

Note

Steve on Image Processing with MATLAB has been archived and will not be updated.

Exporting GeoTIFF files using Mapping Toolbox in R2011a

This is my first post using R2011a, which shipped last week. (MathWorks ships product-line updates twice per year, usually in March and September.) There's a lot of interesting material to write about for this new release.

Because my blog readers have been asking for it for a long time, the first thing I want to mention is the new Mapping Toolbox function geotiffwrite.

Here are a couple of examples from the documentation. The first example reads a layer from a NASA WMS (Web Map Service) server and writes it out to a GeoTIFF file.

nasa = wmsfind('nasa', 'SearchField', 'serverurl');
layerName = 'bluemarbleng';
layer = nasa.refine(layerName,  'SearchField', 'layername', ...
  'MatchType', 'exact');
[A, R] = wmsread(layer(1));
filename = [layerName '.tif'];
geotiffwrite(filename, A, R)
worldmap world
geoshow(filename)

The next example reads an image from an existing GeoTIFF file, and then it writes out the first 1024 columns and last 1024 rows to a new GeoTIFF file.

[A, R] = geotiffread('boston.tif');
row = [size(A,1)-1024+1 size(A,1)];
col = [1 1024];
subImage = A(row(1):row(2), col(1):col(2), :);
xi = col + [-.5 .5];
yi = row + [-.5 .5];
[xlim, ylim] = intrinsicToWorld(R, xi, yi);
subR = R;
subR.RasterSize = size(subImage);
subR.XLimWorld = sort(xlim);
subR.YLimWorld = sort(ylim);
info = geotiffinfo('boston.tif');
filename = 'boston_subimage.tif';
geotiffwrite(filename, subImage, subR,  ...
    'GeoKeyDirectoryTag', info.GeoTIFFTags.GeoKeyDirectoryTag);
mapshow(filename);

If you'd like to know more about the capabilities of this new function, I encourage you to take a look at the extensive new example online.

Stay tuned for more about R2011a...




Published with MATLAB® 7.12

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.