Mapping Toolbox | ![]() ![]() |
Create spatial equirectangular histogram
Syntax
[lat,lon,num,wnum] = histr(lats,lons) [lat,lon,num,wnum] = histr(lats,lons,units) [lat,lon,num,wnum] = histr(lats,lons,bindensty) [lat,lon,num,wnum] = histr(lats,lons,bindensty,units)
Description
This command sorts geographic data into equirectangular bins for histogram purposes. Equirectangular in this context means that each bin has the same angular measurement on each side (e.g., 1º-by-1º). Consequently, the result is not an equal area histogram. The hista
command provides that capability. However, the results of histr
can be weighted by their area bias to, in some sense, correct for this.
[lat,lon,num,wnum] = histr(lats,lons) returns the center coordinates of equal-rectangular bins and the number of observations, num
, falling in each based on the geographically distributed input data. Additionally, an area-weighted observation value, wnum
, is returned. wnum
is the bin's num
divided by its normalized area. The largest bin has the same num
and wnum
; a smaller bins has a larger wnum
than num
.
[lat,lon,num,wnum] = histr(lats,lons,units
) specifies the standard angle unit string. The default value is 'degrees'
.
[lat,lon,num,wnum] = histr(lats,lons,bindensty) sets the number of bins per angular unit. For example, if units
are 'degrees'
, a bindensty
of 10 would be 10 bins per degree of latitude or longitude, resulting in 100 bins per square degree. The default is one cell per angular unit.
Examples
lats = rand(4) lats = 0.4451 0.8462 0.8381 0.8318 0.9318 0.5252 0.0196 0.5028 0.4660 0.2026 0.6813 0.7095 0.4186 0.6721 0.3795 0.4289 longs = rand(4) longs = 0.3046 0.3028 0.3784 0.4966 0.1897 0.5417 0.8600 0.8998 0.1934 0.1509 0.8537 0.8216 0.6822 0.6979 0.5936 0.6449
Bin the data in 0.5-by-0.5 degree cells (2 bins per degree):
[lat,lon,num,wnum] = histr(lats,longs,2); [lat,lon,num,wnum] ans = 0.2500 0.2500 3.0000 3.0000 0.7500 0.2500 4.0000 4.0003 0.2500 0.7500 4.0000 4.0000 0.7500 0.7500 5.0000 5.0004
The bins centered at 0.75°N are slightly smaller in area than the others. wnum
reflects the relative count per normalized unit area.
See Also
filterm |
Geographic filter for data sets |
hista |
Spatial equal area histogram |
![]() | hista | hms2hm | ![]() |