worldfilewrite
Write world file from raster reference object
Description
Examples
Read an image as an array by using the imread function.
A = imread("boston_common.jpg");Spatially reference the image by creating a map cells reference object. For more information about how to spatially reference an image, see Spatially Reference Imported Rasters.
xlimits = [235150 236150];
ylimits = [900100 901100];
R = maprefcells(xlimits,ylimits,size(A),ColumnsStartFrom="north");Write the reference object to a world file. Get the filename for the world file by using the getworldfilename function.
filename = getworldfilename("boston_common.jpg");
worldfilewrite(R,filename)Verify the result. Read the world file into the workspace as a new reference object. Then, display the georeferenced image on a map.
newR = worldfileread(filename,"planar",size(A));
mapshow(A,newR)
The data used in this example is derived from data provided by MassGIS (Bureau of Geographic Information). See the file boston_common.txt for more details.
Input Arguments
Raster reference, specified as a GeographicCellsReference, GeographicPostingsReference, MapCellsReference, or MapPostingsReference object.
Filename, specified as a string scalar or a character vector. You can get the name
of a world file from the name of an image file by using the getworldfilename function. Common world file extensions include
.tfw, .jgw, and .pgw.
The way you specify filename depends on the location you are
writing to.
To write to the current folder, specify the name of the file, such as
"myWorldfile.tfw".To write to a folder different from the current folder, specify the full or relative path name, such as
"C:\myfolder\myWorldfile.jgw"or"dataDir\myWorldfile.pgw".
If filename is the name of an existing file, then
worldfilewrite overwrites the file. If filename
does not already exist, then worldfilewrite creates the file.
Data Types: char | string
Version History
Introduced before R2006aThe worldfilewrite function does not accept referencing matrices as
input. Use a geographic raster reference object (specified as a GeographicCellsReference or GeographicPostingsReference object) or a map raster reference object (specified
as a MapCellsReference or MapPostingsReference object) as input instead.
Reference objects have several advantages over referencing matrices.
Unlike referencing matrices, reference objects have properties that document the size of the associated raster, its limits, and the direction of its rows and columns.
You can manipulate the limits of rasters associated with reference objects using the
geocropormapcropfunction.You can manipulate the size and resolution of rasters associated with reference objects using the
georesizeormapresizefunction.
Depending on whether the referencing matrix is in geographic or planar coordinates, there are different ways to update your code.
Geographic Coordinates
If the referencing matrix is in geographic coordinates, create a geographic reference object.
Create a geographic reference object for a raster of cells by using the
georefcellsfunction.Create a geographic reference object for a raster of regularly posted samples by using the
georefpostingsfunction.Convert from a referencing matrix to a geographic reference object by using the
refmatToGeoRasterReferencefunction.
Once you have created a geographic reference object, replace uses of the referencing matrix in your code with the geographic reference object.
Planar Map Coordinates
If the referencing matrix is in planar map coordinates, create a map reference object.
Create a map reference object for a raster of cells by using the
maprefcellsfunction.Create a map reference object or for a raster of regularly posted samples by using the
maprefpostingsfunction.Convert from a referencing matrix to a map reference object by using the
refmatToMapRasterReferencefunction.
Once you have created a map reference object, replace uses of the referencing matrix in your code with the map reference object.
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.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- 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)