You are on page 1of 5

https://www.mathworks.com/help/map/ref/arcgridread.

html

arcgridread
Read gridded data set in ArcGrid ASCII or GridFloat format

collapse all in page

Syntax
[Z,R] = arcgridread(filename)
[Z,R] = arcgridread(filename,coordinateSystemType)

Description
example

[Z,R] = arcgridread(filename) imports a grid in either ArcGrid ASCII or GridFloat


format from the file specified by filename. Returns Z, a 2-D array containing the data
values, and raster referencing information in R. If the input file is accompanied by a
projection file (with extension .prj or .PRJ), then R is a raster reference object whose type
matches the coordinate reference system defined in the projection file. Otherwise R is a
referencing matrix.

[Z,R] = arcgridread(filename,coordinateSystemType) returns R as a raster


reference object whose type is consistent with the value specified by
coordinateSystemType. This optional input argument can be helpful in the absence of a
projection file. The function throws an error if a projection file is present and
coordinateSystemType contradicts the type of coordinate reference system defined in the
projection file.

Examples
collapse all

Load and View Mount Washington Terrain Elevation Data

Read the data.

[Z,R] = arcgridread('MtWashington-ft.grd');

Display the data as a surface. Add two labels to the display and set the colormap.

mapshow(Z,R,'DisplayType','surface')
xlabel('x (easting in meters)')
ylabel('y (northing in meters)')
demcmap(Z)
View the terrain in 3-D.

axis normal
view(3)
axis equal
grid on
zlabel('elevation in feet')

Input Arguments
collapse all
filename— Name of file containing the grid
character vector

Name of file containing the grid, specified as a character vector. The arcgridread
function supports the following formats.

Format Description
In this format, created by the ArcGIS GRIDASCII command, the data and
ArcGrid header information are in a single text file. arcgridread will also read a .prj
ASCII file, if one is present. This format is also known as Arc ASCII Grid or ESRI
ASCII Raster format.
In this format, created by the ArcGIS GRIDFLOAT command, data and header
information are in separate files (.flt and .hdr). Specify the name of the .flt
GridFloat
file (including the file extension). arcgridread will also read a .prj file, if
one is present. This format is also known as ESRI GridFloat.

Data Types: char

coordinateSystemType — Coordinate system type identifier


'auto' (default) | 'geographic' | 'planar'

Coordinate system type identifier, specified as one of the following values.

Type
Description
Identifier
'geographic'
Returns a geographic cells reference object appropriate to a
latitude/longitude system.
'planar'
Returns a map cells reference object appropriate to a projected map
coordinate system.
'auto' Type of raster reference object determined by the file contents.

Data Types: char

Output Arguments
collapse all

Z — Gridded data set


2-D array

Gridded data set, returned as a 2-D array. The class of the array depends on the format of
the data, described in the following table. arcgridread assigns NaN to elements of Z
corresponding to null data values in the grid file.

Format Class of Returned Gridded Data


ArcGrid ASCII 2-D array of class double.
Format Class of Returned Gridded Data
GridFloat 2-D array of class single.

R— Raster referencing information


raster reference object | referencing matrix

Raster referencing information, returned as a raster reference object whose type matches
the coordinates reference system defined in the projection file. If no projection file exists
and you do not specify thecoordinateSystemType parameter,R is a referencing matrix.

Tips
 The arcgridread function does not import data in the ArcGrid Binary format (also
known as ArcGrid, Arc/INFO Grid, and ESRI ArcInfo Grid). ArcGIS uses this
format internally and it uses multiple files in a folder with standard names such as
hdr.adf and w001001.adf.

See Also
geotiffread | sdtsdemread | worldfileread

Introduced before R2006a


http://www.mathworks.com/matlabcentral/fileexchange/21785-
ascii2xyz?focused=5104240&tab=function

ascii2xyz
version 1.1 (2.63 KB) by Andrew Stevens

convert ARC ASCII text file to xyz

ASCII2XYZ reads in a raster text file in ARC ASCII format and converts values to a m x 3
matrix of x, y, a z values.

This code is mostly vectorized and performs well with reasonably large files (see example
below).

%read in a 25 MB file
a=dir('foo.txt')

a=

name: 'foo.txt'
date: '17-Oct-2008 08:53:34'
bytes: 25437683
isdir: 0
datenum: 7.3370e+005

tic
xyz=ascii2xyz('foo.txt');
toc
Elapsed time is 8.110956 seconds.

You might also like