Main Content

hista

Bin counts for geographic points using equal-area bins

Syntax

[latbin,lonbin,count] = hista(lat,lon)
[latbin,lonbin,count] = hista(lat,lon,binarea)
[latbin,lonbin,count] = hista(lat,lon,binarea,spheroid)
[latbin,lonbin,count] = hista(___,angleunits)

Description

[latbin,lonbin,count] = hista(lat,lon) bins the geographic locations indicated by vectors lat and lon, using equal area binning on a sphere. The default bin area is 100 square kilometers. The latbin and lonbin outputs are column vectors indicating the centers of non-empty bins. count matches latbin and lonbin in size, with each element containing a positive integer equal to the number of occurrences in the corresponding bin.

Binning is performed on a mesh within a quadrangle whose latitude and longitude limits match the extrema of the input locations. The input and output latitudes and longitudes are in units of degrees.

[latbin,lonbin,count] = hista(lat,lon,binarea) uses the bin size specified by the input binarea, which must be in square kilometers

[latbin,lonbin,count] = hista(lat,lon,binarea,spheroid) bins the data on the reference spheroid defined by spheroid. spheroid is a referenceEllipsoid (oblateSpheroid) object, a referenceSphere object, or a vector of the form [semimajor_axis eccentricity]. The eccentricity/flattening of the spheroid is used in determining the latitude extent of the bins. The semimajor axis of the spheroid is used to determine the longitude extent of the bins, but if the length unit of the spheroid is unspecified, the mean radius of the earth in kilometers is used as the equatorial radius.

[latbin,lonbin,count] = hista(___,angleunits) where angleunits defines the angle units of the inputs and outputs, specified as 'degrees' or 'radians'.

Examples

collapse all

Create some random latitudes.

rng(0,'twister')
lats = rand(4)
lats = 4×4

    0.8147    0.6324    0.9575    0.9572
    0.9058    0.0975    0.9649    0.4854
    0.1270    0.2785    0.1576    0.8003
    0.9134    0.5469    0.9706    0.1419

Create some random longitudes.

lons = rand(4)
lons = 4×4

    0.4218    0.6557    0.6787    0.6555
    0.9157    0.0357    0.7577    0.1712
    0.7922    0.8491    0.7431    0.7060
    0.9595    0.9340    0.3922    0.0318

Bin the data in 50-by-50 km cells (2500 sq km).

[lat,lon,num] = hista(lats,lons,2500);

[lat,lon,num]
ans = 9×3

    0.0932   -0.0208    2.0000
    0.5341    0.3235    1.0000
    0.9750    0.3235    2.0000
    0.0932    0.6678    2.0000
    0.5341    0.6678    1.0000
    0.9750    0.6678    4.0000
    0.0932    1.0122    1.0000
    0.5341    1.0122    1.0000
    0.9750    1.0122    2.0000

Version History

Introduced before R2006a

See Also

| |