The band arithmetic function takes a georaster and an arithmetic operation. The function performs pixel-by-pixel calculation according to the arithmetic operation provided. This is only possible for a multiband raster and not for single band rasters. The output is a computed single band raster.

bandArithmetic

Parameters

operation

`(String)`

a string representation of an arithmetic operation to perform
Returns

`GeoRaster`

:
the computed georaster
Example

```
// naip.tif has 4-bands: red (a), green (b), blue (c) and near-infrared (d)
const ndvi = await geoblaze.bandArithmetic("https://example.org/naip.tif", '(d - a)/(d + a)')
// or if you want to preload the georaster, so you can use it later, too
const georaster = await geoblaze.load("https://example.org/naip.tif");
const ndvi = await geoblaze.bandArithmetic(georaster, '(c - b)/(c + b)');
```

The get function takes a georaster and a bounding box as input. It returns the subset of pixels in the georaster found within the bounding box. It also takes an optional parameter "flat" which will flatten the returning pixel matrix across bands, so that for each band all the rows will be combined into one long array.

get

Parameters

boundingBox

`(Object)`

can be an
[xmin, ymin, xmax, ymax]
array, a [[
[x00,y00]
,...,
[x0n,y0n]
,
[x00,y00]
]...] GeoJSON polygon object, or a string representation of a GeoJSON polygon object.
flat

`(Boolean)`

whether or not the resulting output should be flattened into a single array for each band
Returns

`Object`

:
array of pixel values
Example

`const pixels = await geoblaze.get(georaster, geometry);`

The histogram function takes a georaster as an input and an optional geometry. If a geometry is included, the function returns the histogram of all the pixels in that area. If no geometry is included, the function returns the histogram of all the pixels for each band in the georaster.

histogram

Parameters

input

```
(Object
=
````undefined`

)

a geometry, which we'll use for clipping result
Returns

`Object`

:
array of histograms for each band
Example

```
// naip.tif has 4-bands: red, green, blue and near-infrared
const url = "https://example.org/naif.tif";
// calculate the raw histogram pixel values
const histograms = await geoblaze.histogram(url, geometry, { scaleType: "nominal" });
// break histograms into 10 bins for each band
const histograms = await geoblaze.histogram(url, geometry, { scaleType: "ratio", numClasses: 10, classType: "equal-interval" });
```

Given a raster and a point geometry, the identify function returns the pixel value of the raster at the given point. The raster and point must share the same Spatial Reference System.

identify

Parameters

Example

```
// based on https://observablehq.com/@danieljdufour/identify-single-pixel-value-in-geotiff
const url = "https://s3.amazonaws.com/geoblaze/wildfires.tiff";
// point as [longitude, latitude]
const cityOfRedding = [-122.366667, 40.583333];
const results = await geoblaze.identify(url, cityOfRedding);
// results are [red, green, blue]
[76, 76, 68]
```

This function loads a whole file into memory as a georaster. If you pass in a url, it will fetch the whole file. It is the heavy-weight alternative to geoblaze.parse and should only be used if your file is relatively small or you have a really good reason for loading the whole file into memory, like running band arithmetic to create a new file. In general, use geoblaze.parse instead of geoblaze.load.

load

Parameters

Example

```
// naip.tif has 4-bands: red, green, blue and near-infrared
const url = "https://example.org/naif.tif";
const georaster = await geoblaze.load(url);
const mins = geoblaze.min(georaster);
const maxs = geoblaze.max(georaster);
const ndvi = geoblaze.bandArithmetic(georaster, "(d - a) / (d + a)");
```

The max function takes a georaster and an optional geometry. If a geometry is included, the function returns the max of all the pixels in that area. If no geometry is included, the function returns the max of all the pixels for each band in the raster.

max

Parameters

geometry

`(Object)`

geometry can be an
[xmin, ymin, xmax, ymax]
array for a bounding box, [[
[x00,y00]
,...,
[x0n,y0n]
,
[x00,y00]
]...] for a polygon, a GeoJSON polygon object, or a string representation of a GeoJSON polygon object.
Returns

`Array<Number>`

:
array of maxs for each band
Example

```
// naip.tif has 4-bands: red, green, blue and near-infrared (nir)
const url = "https://example.org/naif.tif";
const maxs = await geoblaze.max(url, geometry);
// maxs is [red, green, blue, nir]
[231, 242, 254, 255]
```

The min function takes a georaster as an input and an optional geometry. If a geometry is included, the function returns the min of all the pixels in that area for each band. If no geometry is included, the function returns the min of all the pixels for each band in the raster.

min

Parameters

`(Object)`

geometry can be an
[xmin, ymin, xmax, ymax]
array for a bounding box, [[
[x00,y00]
,...,
[x0n,y0n]
,
[x00,y00]
]...] for a polygon, a GeoJSON polygon object, or a string representation of a GeoJSON polygon object.
Returns

`Array<Number>`

:
array of mins for each band
Example

```
// naip.tif has 4-bands: red, green, blue and near-infrared (nir)
const url = "https://example.org/naif.tif";
const mins = await geoblaze.min(url, geometry);
// mins is [red, green, blue, nir]
[1, 4, 9, 4]
```

The mean function takes a georaster and an optional geometry. If a geometry is included, the function returns the mean of all the pixels in that area. If no geometry is included, the function returns the mean of all the pixels for each band in the raster.

mean

Parameters

`(Object)`

geometry can be an
[xmin, ymin, xmax, ymax]
array for a bounding box, [[
[x00,y00]
,...,
[x0n,y0n]
,
[x00,y00]
]...] for a polygon, a GeoJSON polygon object, or a string representation of a GeoJSON polygon object.
Returns

`Array<Number>`

:
array of means for each band
Example

```
// naip.tif has 4-bands: red, green, blue and near-infrared (nir)
const url = "https://example.org/naif.tif";
const means = await geoblaze.mean(url, geometry);
// means is [red, green, blue, nir]
[42, 84, 92, 94]
```

The median function takes a raster and an optional geometry. If a geometry is included, the function returns the median of all the pixels in that area. If no geometry is included, the function returns the median of all the pixels for each band in the raster.

median

Parameters

`(Object)`

geometry can be an
[xmin, ymin, xmax, ymax]
array for a bounding box, [[
[x00,y00]
,...,
[x0n,y0n]
,
[x00,y00]
]...] for a polygon, a GeoJSON polygon object, or a string representation of a GeoJSON polygon object.
Returns

`Array<Number>`

:
array of medians for each band
Example

```
// naip.tif has 4-bands: red, green, blue and near-infrared (nir)
const url = "https://example.org/naif.tif";
const medians = await geoblaze.median(url, geometry);
// medians is [red, green, blue, nir]
[42, 84, 92, 94]
```

The mode function takes a georaster and an optional geometry. If a geometry is included, the function returns the mode of all the pixels in that area. If no geometry is included, the function returns the mode of all the pixels for each band in the georaster. If there is more than one mode for a band, it computes the mean among those modes.

mode

Parameters

`(Object)`

geometry can be an
[xmin, ymin, xmax, ymax]
array for a bounding box, [[
[x00,y00]
,...,
[x0n,y0n]
,
[x00,y00]
]...] for a polygon, a GeoJSON polygon object, or a string representation of a GeoJSON polygon object.
Returns

`Array<Number>`

:
array of modes for each band
Example

```
// naip.tif has 4-bands: red, green, blue and near-infrared (nir)
const url = "https://example.org/naif.tif";
const results = await geoblaze.mode(url, geometry);
// results is [red, green, blue, nir]
[42, 84, 92, 94]
```

The modes function takes a georaster and an optional geometry. If a geometry is included, the function returns the modes of all the pixels in that area. If no geometry is included, the function returns the modes of all the pixels for each band in the georaster. Unlike the mode function, it will not compute the mean, but return all the most common values for each band.

modes

Parameters

`(Object)`

geometry can be an
[xmin, ymin, xmax, ymax]
array for a bounding box, [[
[x00,y00]
,...,
[x0n,y0n]
,
[x00,y00]
]...] for a polygon, a GeoJSON polygon object, or a string representation of a GeoJSON polygon object.
Returns

`Array<Array<Number>>`

:
array of modes for each band
Example

```
// naip.tif has 4-bands: red, green, blue and near-infrared (nir)
const url = "https://example.org/naif.tif";
const results = await geoblaze.mode(url, geometry);
// results is [ [red], [green], [blue], [nir] ]
[[ 42, 43] , [83, 82, 84], [92], [94]]
```

The parse function takes a georaster (as an object, array buffer, blob, buffer, file or url) and returns a promise. The promise resolves to a georaster, which can be used as input in other geoblaze methods, such as identify, sum, or histogram. This function essentially call's georaster's parseGeoRaster function.

parse

Parameters

Example

```
import { parse } from "geoblaze";
// parse url
const georaster = await parse("https://example.org/naif.tif");
// parse array buffer
const response = await fetch("https://example.org/naif.tif");
const arrayBuffer = await response.arrayBuffer();
const georaster = await parse(arrayBuffer);
// parse buffer (in NodeJS)
import { readFileSync } from "fs";
const buffer = readFileSync("naip.tif");
const georaster = await parse(buffer);
```

The raster calculator function takes a georaster and a javascript function as input. The function is performed pixel-by-pixel on each cell in the raster. The arguments to the function should reference bands in the order in the raster

rasterCalculator

Parameters

function

`(Function)`

a JavaScript function representing an arithmetic operation to perform
Returns

`GeoRaster`

:
georaster - the computed georaster
Example

```
// 3-band GeoTIFF with bands (a) red, (b) green, and (c) blue
const url = "https://example.org/rgb.tif"
const filteredRaster = geoblaze.rasterCalculator(url, (a, b, c) => a + b === c ? 1 : 0);
```

The stats function takes a georaster and an optional geometry. It then uses the calc-stats library to calculate statistics for each band.

stats

Parameters

`(Object)`

geometry can be an
[xmin, ymin, xmax, ymax]
array for a bounding box, [[
[x00,y00]
,...,
[x0n,y0n]
,
[x00,y00]
]...] for a polygon, a GeoJSON polygon object, or a string representation of a GeoJSON polygon object.
Returns

`Object`

:
array of stats for each band
Example

```
const stats = await geoblaze.stats("https://example.org/imagery.tif", geometry);
[{ median: 906.7, min: 0, max: 5166.7, sum: 262516.5, mean: 1232.4718309859154, modes: [0], mode: 0, histogram: { 0: 12, 1: 74, 2: 573, ... } }]
```

The sum function takes a georaster and an optional geometry. If a geometry is included, the function returns the sum of all the pixels in that area. If no geometry is included, the function returns the sum of all the pixels for each band in the georaster.

sum

Parameters

`(Object)`

geometry can be an
[xmin, ymin, xmax, ymax]
array for a bounding box, [[
[x00,y00]
,...,
[x0n,y0n]
,
[x00,y00]
]...] for a polygon, a GeoJSON polygon object, or a string representation of a GeoJSON polygon object.
Returns

`Array<Number>`

:
array of sums for each band
Example

```
// naip.tif has 4-bands: red, green, blue and near-infrared (nir)
const url = "https://example.org/naif.tif";
const results = await geoblaze.sum(url, geometry);
// results is [red, green, blue, nir]
[217461, 21375, 57312, 457125]
```