mergetiles
Description
Examples
Import adjacent raster tiles, merge the tiles into a single raster, and display the merged raster on a map.
Read four DTED tiles into the workspace. The tiles form a quadrangle with latitudes from 39 to 41 degrees and longitudes from –107 to –105 degrees. For each use of the readgeoraster
function, the first output is an array that contains elevation values, and the second output is a reference object that contains spatial referencing information.
[A1,R1] = readgeoraster("w106/n39.dt0",OutputType="double"); [A2,R2] = readgeoraster("w106/n40.dt0",OutputType="double"); [A3,R3] = readgeoraster("w107/n39.dt0",OutputType="double"); [A4,R4] = readgeoraster("w107/n40.dt0",OutputType="double");
Merge the tiles into one raster.
[B,RB] = mergetiles(A1,R1,A2,R2,A3,R3,A4,R4);
Create a map and display the merged raster as a surface. Apply a colormap that is appropriate for elevation data. Then, add a labeled color bar.
usamap(B,RB) geoshow(B,RB,DisplayType="surface") demcmap(B) c = colorbar; c.Label.String = "Elevation (m)";
This example uses modified data from the US Geological Survey.
The mergetiles
function requires the input raster tiles to form a filled quadrangle or rectangle. If your data has missing tiles, then you can fill the gaps with values that represent missing data.
Read three DTED tiles into the workspace:
w106/n39.dt0
has latitudes from 39 to 40 degrees and longitudes from –106 to –105 degrees.w106/n40.dt0
has latitudes from 40 to 41 degrees and longitudes from –106 to –105 degrees.w107/n39.dt0
has latitudes from 39 to 40 degrees and longitudes from –107 to –106 degrees.
[A1,R1] = readgeoraster("w106/n39.dt0",OutputType="double"); [A2,R2] = readgeoraster("w106/n40.dt0",OutputType="double"); [A3,R3] = readgeoraster("w107/n39.dt0",OutputType="double");
The tiles are bound by a quadrangle with latitudes from 39 to 41 degrees and longitudes from –107 to –105 degrees. However, the quadrangle is missing the tile with latitudes from 40 to 41 degrees and longitudes from –107 to –106.
To merge the three DTED tiles by using the mergetiles
function, you can create a fourth tile of NaN
values that accounts for the missing data. If the NaN
function does not support the data type of your tiles, such as uint8
values in tiles of RGB data, then you can use numeric values such as 0
s or 1
s.
Spatially reference the tile by making a copy of one of the existing reference objects. Then, change the latitude and longitude limits of the new reference object to match the limits of the missing tile.
Create an array of
NaN
values. Specify the size of the array using the raster size stored in the new reference object.
missingR = R3; missingR.LatitudeLimits = [40 41]; missingR.LongitudeLimits = [-107 -106]; missingA = NaN(missingR.RasterSize);
Merge the DTED tiles and the tile of NaN
values into one raster.
[B,RB] = mergetiles(A1,R1,A2,R2,A3,R3,missingA,missingR);
Create a map and display the merged raster as a surface. Note that the northwest corner of the map is blank. Apply a colormap that is appropriate for elevation data. Then, add a labeled color bar.
figure usamap(B,RB) geoshow(B,RB,DisplayType="surface") demcmap(B) c = colorbar; c.Label.String = "Elevation (m)";
This example uses modified data from the US Geological Survey.
Input Arguments
Georeferenced image or data grid, specified as an M-by-N numeric or logical matrix or an M-by-N-by-P numeric or logical array.
The data types of the input images or data grids must match.
Spatial reference for the image or data grid, specified as a GeographicCellsReference
, GeographicPostingsReference
, MapCellsReference
, or MapPostingsReference
object.
The object types of the input reference objects must match. In addition, the input reference objects must be consistent.
GeographicCellsReference
objects are consistent when the values of theCellExtentInLatitude
,CellExtentInLongitude
,GeographicCRS
,RowsStartFrom
, andColumnsStartFrom
properties match.GeographicPostingsReference
objects are consistent when the values of theSampleSpacingInLatitude
,SampleSpacingInLongitude
,GeographicCRS
,RowsStartFrom
, andColumnsStartFrom
properties match.MapCellsReference
objects are consistent when the values of theCellExtentInWorldX
,CellExtentInWorldY
,ProjectedCRS
,RowsStartFrom
, andColumnsStartFrom
properties match.MapPostingsReference
objects are consistent when the values of theSampleSpacingInWorldX
,SampleSpacingInWorldY
,ProjectedCRS
,RowsStartFrom
, andColumnsStartFrom
properties match.
Output Arguments
Georeferenced image or data grid, returned as an M-by-N numeric or logical matrix or an M-by-N-by-P numeric or logical array.
The data type of B
matches the data type of the input images or
data grids.
Spatial reference for the merged image or data grid, returned as a GeographicCellsReference
, GeographicPostingsReference
, MapCellsReference
, or MapPostingsReference
object.
The object type of RB
matches the object type of the input
reference objects.
Tips
To simultaneously read and merge multiple adjacent raster tiles, you can create a custom datastore. For more information about using custom datastores to read and merge multiple tiles, see Merge Multiple Raster Tiles Using Datastore.
Version History
Introduced in R2024a
See Also
Functions
Objects
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)