⚠️ Our 0.1 release refactored several early-development functions for long-term stability, to update your code see here. ⚠️
Future changes will come with deprecation warnings! 🙂



classmethod Raster.from_array(data, transform, crs, nodata=None, area_or_point=None, tags=None, cast_nodata=True)[source]#

Create a raster from a numpy array and the georeferencing information.

Expects a 2D (single band) or 3D (multi-band) array of the raster. The first axis corresponds to bands.

  • data (ndarray[Any, dtype[Union[floating[Any], integer[Any]]]] | MaskedArray[Any, dtype[Union[floating[Any], integer[Any]]]] | ndarray[Any, dtype[bool_]]) – Input array, 2D for single band or 3D for multi-band (bands should be first axis).

  • transform (tuple[float, ...] | Affine) – Affine 2D transform. Either a tuple(x_res, 0.0, top_left_x, 0.0, y_res, top_left_y) or an affine.Affine object.

  • crs (CRS | int | None) – Coordinate reference system. Any CRS supported by Pyproj (e.g., CRS object, EPSG integer).

  • nodata (int | float | None) – Nodata value.

  • area_or_point (Optional[Literal['Area', 'Point']]) – Pixel interpretation of the raster, will be stored in AREA_OR_POINT metadata.

  • tags (dict[str, Any]) – Metadata stored in a dictionary.

  • cast_nodata (bool) – Automatically cast nodata value to the default nodata for the new array type if not compatible. If False, will raise an error when incompatible.

Return type:

TypeVar(RasterType, bound= Raster)


Raster created from the provided array and georeferencing.


You have a data array in EPSG:32645. It has a spatial resolution of 30 m in x and y, and its top left corner is X=478000, Y=3108140.

>>> data = np.ones((500, 500), dtype="uint8")
>>> transform = (30.0, 0.0, 478000.0, 0.0, -30.0, 3108140.0)
>>> myim = Raster.from_array(data, transform, 32645)