Main Content

Precompute the Size of a Data Grid

Before making a large, memory-taxing data grid, you should first determine what its size will be. If you know the latitude and longitude limits of a region, you can calculate the size of the raster by creating a referencing object, for any desired map resolution and scale.

Specify the latitude and longitude limits for the region. This example calculates the size of a map of the continental U.S. at a scale of 10 cells per degree.

latlim = [  25  50];
lonlim = [-130 -60];

Specify the extent of the data grid using cells per degree.

cellsPerDegree = 10;
extent = 1/cellsPerDegree;

Construct a referencing object and verify that the size of the raster is reasonable (in this case, 250 by 700 cells).

R = georefcells(latlim,lonlim,extent,extent);
ans = 1×2

   250   700