Compute Tropical Livestock Units (TLU) by combining GLW4 species density layers with standard conversion factors, streaming directly from the Hub's Zarr store.
Livestock density is published one species at a time — cattle, buffalo, sheep, goats — but many analyses want a single grazing-pressure number. The Tropical Livestock Unit (TLU) provides that: each animal counts as a fraction of a 250 kg reference animal, so species can be weighted and summed into one comparable layer.
This notebook builds a TLU/km² map from Gridded Livestock of the World v4 , streaming just the data it needs — nothing is downloaded ahead of time.
GLW4 lives on object storage as a Zarr cube, so xarray opens it over HTTPS and only ever reads the chunks a computation touches. Inspecting the dataset shows one density variable per species, in head/km².
ds = xr.open_zarr(
"https://digital-atlas.s3.amazonaws.com/cdh/data/glw4-2020/glw4-2020.zarr"
)
<xarray.Dataset> Size: 224MB
Dimensions: (y: 2160, x: 4320)
Coordinates:
* y (y) float64 17kB 89.96 89.88 89.79 ... -89.79 -89.87 -89.96
* x (x) float64 35kB -180.0 -179.9 -179.8 ... 179.8 179.9 180.0
Data variables:
buffalo (y, x) float32 37MB dask.array<chunksize=(1080, 1080), meta=np.ndarray>
cattle (y, x) float32 37MB dask.array<chunksize=(1080, 1080), meta=np.ndarray>
chicken (y, x) float32 37MB dask.array<chunksize=(1080, 1080), meta=np.ndarray>
goat (y, x) float32 37MB dask.array<chunksize=(1080, 1080), meta=np.ndarray>
pig (y, x) float32 37MB dask.array<chunksize=(1080, 1080), meta=np.ndarray>
sheep (y, x) float32 37MB dask.array<chunksize=(1080, 1080), meta=np.ndarray>
spatial_ref int64 8B ...
Attributes:
title: GLW4 2020 livestock density
source: Gridded Livestock of the World v4 (GLW4), 2020, dasymetric Dimensions: Coordinates: (2)
Data variables: (7)
buffalo
(y, x)
float32
dask.array<chunksize=(1080, 1080), meta=np.ndarray>
long_name : Buffalo density units : head/km2 source_url : https://storage.googleapis.com/fao-gismgr-glw4-2020-data/DATA/GLW4-2020/MAPSET/D-DA/GLW4-2020.D-DA.BFL.tif spatial:dimensions : ['y', 'x'] spatial:bbox : [-180.0, -89.99999999999994, 179.99999999999983, 90.0] spatial:transform_type : affine spatial:transform : [0.0833333333333333, 0.0, -180.0, 0.0, -0.0833333333333333, 90.0] spatial:shape : [2160, 4320] spatial:registration : pixel proj:code : EPSG:4326 zarr_conventions : [{'uuid': '689b58e2-cf7b-45e0-9fff-9cfc0883d6b4', 'schema_url': 'https://raw.githubusercontent.com/zarr-conventions/spatial/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-conventions/spatial/blob/v1/README.md', 'name': 'spatial:', 'description': 'Spatial coordinate information'}, {'uuid': 'f17cb550-5864-4468-aeb7-f3180cfb622f', 'schema_url': 'https://raw.githubusercontent.com/zarr-experimental/geo-proj/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-experimental/geo-proj/blob/v1/README.md', 'name': 'proj:', 'description': 'Coordinate reference system information for geospatial data'}]
Array
Chunk
Bytes
35.60 MiB
4.45 MiB
Shape
(2160, 4320)
(1080, 1080)
Dask graph
8 chunks in 2 graph layers
Data type
float32 numpy.ndarray
4320
2160
cattle
(y, x)
float32
dask.array<chunksize=(1080, 1080), meta=np.ndarray>
long_name : Cattle density units : head/km2 source_url : https://storage.googleapis.com/fao-gismgr-glw4-2020-data/DATA/GLW4-2020/MAPSET/D-DA/GLW4-2020.D-DA.CTL.tif spatial:dimensions : ['y', 'x'] spatial:bbox : [-180.0, -89.99999999999994, 179.99999999999983, 90.0] spatial:transform_type : affine spatial:transform : [0.0833333333333333, 0.0, -180.0, 0.0, -0.0833333333333333, 90.0] spatial:shape : [2160, 4320] spatial:registration : pixel proj:code : EPSG:4326 zarr_conventions : [{'uuid': '689b58e2-cf7b-45e0-9fff-9cfc0883d6b4', 'schema_url': 'https://raw.githubusercontent.com/zarr-conventions/spatial/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-conventions/spatial/blob/v1/README.md', 'name': 'spatial:', 'description': 'Spatial coordinate information'}, {'uuid': 'f17cb550-5864-4468-aeb7-f3180cfb622f', 'schema_url': 'https://raw.githubusercontent.com/zarr-experimental/geo-proj/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-experimental/geo-proj/blob/v1/README.md', 'name': 'proj:', 'description': 'Coordinate reference system information for geospatial data'}]
Array
Chunk
Bytes
35.60 MiB
4.45 MiB
Shape
(2160, 4320)
(1080, 1080)
Dask graph
8 chunks in 2 graph layers
Data type
float32 numpy.ndarray
4320
2160
chicken
(y, x)
float32
dask.array<chunksize=(1080, 1080), meta=np.ndarray>
long_name : Chicken density units : head/km2 source_url : https://storage.googleapis.com/fao-gismgr-glw4-2020-data/DATA/GLW4-2020/MAPSET/D-DA/GLW4-2020.D-DA.CHK.tif spatial:dimensions : ['y', 'x'] spatial:bbox : [-180.0, -89.99999999999994, 179.99999999999983, 90.0] spatial:transform_type : affine spatial:transform : [0.0833333333333333, 0.0, -180.0, 0.0, -0.0833333333333333, 90.0] spatial:shape : [2160, 4320] spatial:registration : pixel proj:code : EPSG:4326 zarr_conventions : [{'uuid': '689b58e2-cf7b-45e0-9fff-9cfc0883d6b4', 'schema_url': 'https://raw.githubusercontent.com/zarr-conventions/spatial/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-conventions/spatial/blob/v1/README.md', 'name': 'spatial:', 'description': 'Spatial coordinate information'}, {'uuid': 'f17cb550-5864-4468-aeb7-f3180cfb622f', 'schema_url': 'https://raw.githubusercontent.com/zarr-experimental/geo-proj/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-experimental/geo-proj/blob/v1/README.md', 'name': 'proj:', 'description': 'Coordinate reference system information for geospatial data'}]
Array
Chunk
Bytes
35.60 MiB
4.45 MiB
Shape
(2160, 4320)
(1080, 1080)
Dask graph
8 chunks in 2 graph layers
Data type
float32 numpy.ndarray
4320
2160
goat
(y, x)
float32
dask.array<chunksize=(1080, 1080), meta=np.ndarray>
long_name : Goat density units : head/km2 source_url : https://storage.googleapis.com/fao-gismgr-glw4-2020-data/DATA/GLW4-2020/MAPSET/D-DA/GLW4-2020.D-DA.GTS.tif spatial:dimensions : ['y', 'x'] spatial:bbox : [-180.0, -89.99999999999994, 179.99999999999983, 90.0] spatial:transform_type : affine spatial:transform : [0.0833333333333333, 0.0, -180.0, 0.0, -0.0833333333333333, 90.0] spatial:shape : [2160, 4320] spatial:registration : pixel proj:code : EPSG:4326 zarr_conventions : [{'uuid': '689b58e2-cf7b-45e0-9fff-9cfc0883d6b4', 'schema_url': 'https://raw.githubusercontent.com/zarr-conventions/spatial/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-conventions/spatial/blob/v1/README.md', 'name': 'spatial:', 'description': 'Spatial coordinate information'}, {'uuid': 'f17cb550-5864-4468-aeb7-f3180cfb622f', 'schema_url': 'https://raw.githubusercontent.com/zarr-experimental/geo-proj/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-experimental/geo-proj/blob/v1/README.md', 'name': 'proj:', 'description': 'Coordinate reference system information for geospatial data'}]
Array
Chunk
Bytes
35.60 MiB
4.45 MiB
Shape
(2160, 4320)
(1080, 1080)
Dask graph
8 chunks in 2 graph layers
Data type
float32 numpy.ndarray
4320
2160
pig
(y, x)
float32
dask.array<chunksize=(1080, 1080), meta=np.ndarray>
long_name : Pig density units : head/km2 source_url : https://storage.googleapis.com/fao-gismgr-glw4-2020-data/DATA/GLW4-2020/MAPSET/D-DA/GLW4-2020.D-DA.PGS.tif spatial:dimensions : ['y', 'x'] spatial:bbox : [-180.0, -89.99999999999994, 179.99999999999983, 90.0] spatial:transform_type : affine spatial:transform : [0.0833333333333333, 0.0, -180.0, 0.0, -0.0833333333333333, 90.0] spatial:shape : [2160, 4320] spatial:registration : pixel proj:code : EPSG:4326 zarr_conventions : [{'uuid': '689b58e2-cf7b-45e0-9fff-9cfc0883d6b4', 'schema_url': 'https://raw.githubusercontent.com/zarr-conventions/spatial/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-conventions/spatial/blob/v1/README.md', 'name': 'spatial:', 'description': 'Spatial coordinate information'}, {'uuid': 'f17cb550-5864-4468-aeb7-f3180cfb622f', 'schema_url': 'https://raw.githubusercontent.com/zarr-experimental/geo-proj/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-experimental/geo-proj/blob/v1/README.md', 'name': 'proj:', 'description': 'Coordinate reference system information for geospatial data'}]
Array
Chunk
Bytes
35.60 MiB
4.45 MiB
Shape
(2160, 4320)
(1080, 1080)
Dask graph
8 chunks in 2 graph layers
Data type
float32 numpy.ndarray
4320
2160
sheep
(y, x)
float32
dask.array<chunksize=(1080, 1080), meta=np.ndarray>
long_name : Sheep density units : head/km2 source_url : https://storage.googleapis.com/fao-gismgr-glw4-2020-data/DATA/GLW4-2020/MAPSET/D-DA/GLW4-2020.D-DA.SHP.tif spatial:dimensions : ['y', 'x'] spatial:bbox : [-180.0, -89.99999999999994, 179.99999999999983, 90.0] spatial:transform_type : affine spatial:transform : [0.0833333333333333, 0.0, -180.0, 0.0, -0.0833333333333333, 90.0] spatial:shape : [2160, 4320] spatial:registration : pixel proj:code : EPSG:4326 zarr_conventions : [{'uuid': '689b58e2-cf7b-45e0-9fff-9cfc0883d6b4', 'schema_url': 'https://raw.githubusercontent.com/zarr-conventions/spatial/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-conventions/spatial/blob/v1/README.md', 'name': 'spatial:', 'description': 'Spatial coordinate information'}, {'uuid': 'f17cb550-5864-4468-aeb7-f3180cfb622f', 'schema_url': 'https://raw.githubusercontent.com/zarr-experimental/geo-proj/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-experimental/geo-proj/blob/v1/README.md', 'name': 'proj:', 'description': 'Coordinate reference system information for geospatial data'}]
Array
Chunk
Bytes
35.60 MiB
4.45 MiB
Shape
(2160, 4320)
(1080, 1080)
Dask graph
8 chunks in 2 graph layers
Data type
float32 numpy.ndarray
4320
2160
spatial_ref
()
int64
...
crs_wkt : GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]] semi_major_axis : 6378137.0 semi_minor_axis : 6356752.314245179 inverse_flattening : 298.257223563 reference_ellipsoid_name : WGS 84 longitude_of_prime_meridian : 0.0 prime_meridian_name : Greenwich geographic_crs_name : WGS 84 horizontal_datum_name : World Geodetic System 1984 grid_mapping_name : latitude_longitude spatial_ref : GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AXIS["Latitude",NORTH],AXIS["Longitude",EAST],AUTHORITY["EPSG","4326"]] GeoTransform : -180.0 0.0833333333333333 0.0 90.0 0.0 -0.0833333333333333 [1 values with dtype=int64] Attributes: (2)
title : GLW4 2020 livestock density source : Gridded Livestock of the World v4 (GLW4), 2020, dasymetric
The FAO weights express each species as a fraction of a 250 kg tropical reference animal — a head of cattle counts as 0.7 TLU, a sheep or goat as 0.1. Multiplying each species layer by its weight and summing collapses the cube into a single TLU/km² surface.
# Tropical Livestock Unit weights
# head/km² × weight = TLU/km².
TLU_RUMINANT = {
"cattle" : 0.7 ,
"buffalo" : 0.7 ,
"sheep" : 0.1 ,
"goat" : 0.1 ,
}
layers = [
w * ds[sp].fillna( 0 ) for sp, w in TLU_RUMINANT .items()
]
da = (
xr.concat(layers, dim = "species" )
.sum( "species" )
.rename( "TLU" )
)
da.attrs[ "units" ] = "TLU/km2"
<xarray.DataArray 'TLU' (y: 2160, x: 4320)> Size: 37MB
dask.array<sum-aggregate, shape=(2160, 4320), dtype=float32, chunksize=(1080, 1080), chunktype=numpy.ndarray>
Coordinates:
* y (y) float64 17kB 89.96 89.88 89.79 89.71 ... -89.79 -89.87 -89.96
* x (x) float64 35kB -180.0 -179.9 -179.8 -179.7 ... 179.8 179.9 180.0
Attributes:
long_name: Cattle density
units: TLU/km2
source_url: https://storage.googleapis.com/fao-gismgr-glw4-2...
spatial:dimensions: ['y', 'x']
spatial:bbox: [-180.0, -89.99999999999994, 179.99999999999983,...
spatial:transform_type: affine
spatial:transform: [0.0833333333333333, 0.0, -180.0, 0.0, -0.083333...
spatial:shape: [2160, 4320]
spatial:registration: pixel
proj:code: EPSG:4326
zarr_conventions: [{'uuid': '689b58e2-cf7b-45e0-9fff-9cfc0883d6b4'... Coordinates: (2)
Attributes: (11)
long_name : Cattle density units : TLU/km2 source_url : https://storage.googleapis.com/fao-gismgr-glw4-2020-data/DATA/GLW4-2020/MAPSET/D-DA/GLW4-2020.D-DA.CTL.tif spatial:dimensions : ['y', 'x'] spatial:bbox : [-180.0, -89.99999999999994, 179.99999999999983, 90.0] spatial:transform_type : affine spatial:transform : [0.0833333333333333, 0.0, -180.0, 0.0, -0.0833333333333333, 90.0] spatial:shape : [2160, 4320] spatial:registration : pixel proj:code : EPSG:4326 zarr_conventions : [{'uuid': '689b58e2-cf7b-45e0-9fff-9cfc0883d6b4', 'schema_url': 'https://raw.githubusercontent.com/zarr-conventions/spatial/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-conventions/spatial/blob/v1/README.md', 'name': 'spatial:', 'description': 'Spatial coordinate information'}, {'uuid': 'f17cb550-5864-4468-aeb7-f3180cfb622f', 'schema_url': 'https://raw.githubusercontent.com/zarr-experimental/geo-proj/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-experimental/geo-proj/blob/v1/README.md', 'name': 'proj:', 'description': 'Coordinate reference system information for geospatial data'}]
Everything so far is lazy — no pixels have moved yet. Slicing before plotting means only the chunks inside the window are downloaded: here a roughly 8°×10° box over Kenya and northern Tanzania. .plot() gives a quick look; the same array is ready for zonal statistics or export.
regional_tlu = da.sel(
y = slice ( 5.0 , - 5.2 ), x = slice ( 34.0 , 42.0 )
)
Change the slice to your own region — the lazy reads mean any window costs only its own chunks. Per-species metadata, licensing, and the citation live on the GLW4 record page , and the weights dictionary is the place to add camels or other species if your context needs them.