The raster module

The raster module can read and write Rasters.

>> var Format = require("geoscript/raster").Format;

raster.Format()

class raster.Format(config)

Create a new Format. The config must contain a source representing the file or URL.

Properties

Format.name

String The type of Format (GeoTIFF, WorldImage).

Format.names

Array Array of Raster names. Most Formats will only contain one Raster.

Methods

Format.read(config)
Arguments
  • configObject An object literal with parameters

name: The name of the Raster (optional). Required if there are more than one Raster in the Format.

proj: The Projection of the Raster (optional).

bounds: The Bounds to read a subset of the entire Raster. Optional, but if included size must also be included.

size: An array of width and height of the Raster. Optional, buf if included bound must also be included.

Format.write(raster, config)
Arguments
  • rasterraster.Raster() The Raster to write to this Format.

  • configObject An object literal of write parameters.

raster.Raster()

class raster.Raster()

A Raster is a spatial data set represented by a grid of cells organized in one or more bands.

Usually, Rasters are read from a Format, but you can create a new Raster from an array or array of numeric values and a geom.Bounds.

Properties

Raster.name

String Get the name of the Raster.

Raster.proj

proj.Projection() Get the Projection.

Raster.bounds

geom.Bounds() Get the Bounds.

Raster.size

Array Get the size of the Raster as an Array of two numbers: width and height

Raster.cols

Number Get the number of columns or the width or the Raster

Raster.rows

Number Get the number of row or the height or the Raster

Raster.bands

Array of raster.Bands() Get an array of Bands

Raster.extrema

Object with min and max arrays with min and max values for each band Get the minimum and maximum values for each band.

Raster.blockSize

Array with width and height of a pixel Get the block size

Raster.pixelSize

Array with width and height of a pixel Get the pixel size

Methods

Raster.getPixel(point)
Arguments

Get a pixel Object with x and y properies.

Raster.getPoint(x, y)
Arguments
  • xNumber The pixel’s x position

  • yNumber The pixel’s y position

Get a geom.Point() for the pixel.

Raster.getValue(pointOrPixel)
Arguments
  • pointOrPixelObject The pixel or geom.Point()

  • typeString The type of value to return (double, int, float, byte, boolean)

Get a value for each band from the Raster.

Raster.getMinimumValue(band)
Arguments
  • namdNumber The band

Get the minimum value for the given band

Raster.getMaximumValue(band)
Arguments
  • namdNumber The band

Get the maximum value for the given band

Raster.crop(bounds)
Arguments
  • boundsgeom.Bound() The Bounds of the new Raster

Crop the current Raster to only include data in the given Bounds.

Raster.crop(geometry)
Arguments
  • geometrygeom.Geometry() The Geometry to use when cropping the Raster

Crop the current Raster to only include data in the given Geometry.

Raster.reproject(projection)
Arguments

Reproject a Raster from one Projection to another Projection.

Raster.reclassify(ranges, options)
Arguments
  • rangesArray An array of object literals with required min, max, and value properties. minIncluded and maxIncluded are optional.

  • optionsObject An object literal with optional band and noData values.

Reclassify the values of the Raster.

raster.Band()

class raster.Band()

An individual layer from a Raster.

Properties

Band.min

Number Get the minimum value from this Band.

Band.max

Number Get the maximum value from this Band.

Band.noData

Array Get the array of no data values.

Band.scale

Number Get the scale.

Band.scale

Number Get the scale.

Band.type

Number Get the Raster type.

Band.description

Number Get the Raster description.

Methods

Band.isNoData(value)
Arguments
  • valueObject The value to check

Determine whether the value is a no data value.