Main Content

arcgridread

(Not recommended) Read gridded data set in ArcGrid ASCII or GridFloat format

arcgridread is not recommended. Use readgeoraster instead. For more information, see Version History.

Description

[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.

example

[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

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)

Figure contains an axes object. The axes object with xlabel x (easting in meters), ylabel y (northing in meters) contains an object of type surface.

View the terrain in 3-D.

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

Figure contains an axes object. The axes object with xlabel x (easting in meters), ylabel y (northing in meters) contains an object of type surface.

Input Arguments

collapse all

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

FormatDescription
ArcGrid ASCIIIn this format, created by the ArcGIS GRIDASCII command, the data and header information are in a single text file. arcgridread will also read a .prj file, if one is present. This format is also known as Arc ASCII Grid or Esri® ASCII Raster format.
GridFloat 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 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

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

Type IdentifierDescription
'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

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.

FormatClass of Returned Gridded Data
ArcGrid ASCII2-D array of class double.
GridFloat 2-D array of class single.

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 the coordinateSystemType 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.

Version History

Introduced before R2006a

collapse all

R2020a: arcgridread is not recommended

arcgridread is not recommended. Use readgeoraster instead. There are no plans to remove arcgridread.

Unlike arcgridread, which returns a referencing matrix in some cases, the readgeoraster function returns a raster reference object. 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. For examples of reference object properties, see GeographicCellsReference and MapPostingsReference.

  • You can manipulate the limits of rasters associated with reference objects using the geocrop or mapcrop functions.

  • You can manipulate the size and resolution of rasters associated with reference objects using the georesize or mapresize functions.

This table shows some typical usages of arcgridread and how to update your code to use readgeoraster instead.

Not RecommendedRecommended
[Z,R] = arcgridread(filename);
[Z,R] = readgeoraster(filename);
[Z,R] = arcgridread(filename,cst);
[Z,R] = readgeoraster(filename, ...
        'CoordinateSystemType',cst);

The readgeoraster function does not automatically replace missing data with NaN values. If your data set uses large negative numbers to indicate missing data, replace instances with NaN values using the standardizeMissing function.

[Z,R] = readgeoraster('MtWashington-ft.grd');
info = georasterinfo('MtWashington-ft.grd');
m = info.MissingDataIndicator;
Z = standardizeMissing(Z,m);