API reference#
This page provides a summary of GeoUtils’ API. For more details and examples, refer to the relevant chapters in the main part of the documentation.
Raster#
Examples using geoutils.Raster
#
Opening a file#
|
The georeferenced raster. |
|
Print summary information about the raster. |
Create from an array#
|
Create a raster from a numpy array and the georeferencing information. |
Unique attributes#
Array of the raster. |
|
Coordinate reference system of the raster. |
|
Geotransform of the raster. |
|
Nodata value of the raster. |
Derived attributes#
Shape (i.e., height, width) of the raster in pixels. |
|
Height of the raster in pixels. |
|
Width of the raster in pixels. |
|
Count of bands loaded in memory if they are, otherwise the one on disk. |
|
Count of bands on disk if it exists. |
|
Band indexes loaded in memory if they are, otherwise on disk. |
|
Band indexes on disk if a file exists. |
|
Resolution (X, Y) of the raster in georeferenced units. |
|
Bounding coordinates of the raster. |
|
Data type of the raster (string representation). |
|
Whether the raster array is loaded. |
|
Whether the array has been modified since it was loaded from disk. |
|
Name of the file on disk, if it exists. |
|
Driver used to read a file on disk. |
Geospatial handling methods#
|
Crop the raster to a given extent. |
|
Reproject raster to a different geotransform (resolution, bounds) and/or coordinate reference system (CRS). |
|
Polygonize the raster into a vector. |
|
Compute proximity distances to the raster target pixels, or to a vector geometry on the raster grid. |
|
Extract raster values at the nearest pixels from the specified coordinates, or reduced (e.g., mean of pixels) from a window around the specified coordinates. |
|
Interpolate raster values at a set of points. |
Plotting#
|
Plot the raster, with axes in projection of image. |
Get or update data methods#
|
Copy the raster in-memory. |
|
Convert data type of the raster. |
|
Set a mask on the raster array. |
|
Set a new nodata value for all bands. |
|
Get NaN array from the raster. |
Get mask of invalid values from the raster. |
|
|
Randomly sample the raster. |
I/O methods#
|
Load the raster array from disk. |
|
Write the raster to file. |
|
Convert raster to point cloud. |
Export to a Rasterio in-memory dataset. |
|
|
Convert raster to a xarray.DataArray. |
Coordinate and extent methods#
|
Get indexes (row,column) of coordinates (x,y). |
|
Get coordinates (x,y) of indexes (row,column). |
|
Get coordinates (x,y) of all pixels in the raster. |
|
Shift a raster by a (x,y) offset. |
|
Check whether a given point falls outside the raster. |
Projection methods#
|
Get local metric coordinate reference system for the raster (UTM, UPS, or custom Mercator or Polar). |
|
Get raster bounds projected in a specified CRS. |
|
Get raster footprint projected in a specified CRS. |
|
Returns the bounding box of intersection between this image and another. |
Testing methods#
|
Check if two rasters are equal. |
|
Check that raster shape, geotransform and CRS are equal. |
Arithmetic with other rasters, arrays or numbers#
|
Sum two rasters, or a raster and a numpy array, or a raster and single number. |
|
Subtract two rasters, or a raster and a numpy array, or a raster and single number. |
Take the raster negation. |
|
|
Multiply two rasters, or a raster and a numpy array, or a raster and single number. |
|
True division of two rasters, or a raster and a numpy array, or a raster and single number. |
|
Floor division of two rasters, or a raster and a numpy array, or a raster and single number. |
|
Modulo of two rasters, or a raster and a numpy array, or a raster and single number. |
|
Power of a raster to a number. |
And reverse operations.
Logical operator casting to Mask#
|
Element-wise equality of two rasters, or a raster and a numpy array, or a raster and single number. |
|
Element-wise negation of two rasters, or a raster and a numpy array, or a raster and single number. |
|
Element-wise lower than comparison of two rasters, or a raster and a numpy array, or a raster and single number. |
|
Element-wise lower or equal comparison of two rasters, or a raster and a numpy array, or a raster and single number. |
|
Element-wise greater than comparison of two rasters, or a raster and a numpy array, or a raster and single number. |
|
Element-wise greater or equal comparison of two rasters, or a raster and a numpy array, or a raster and single number. |
Array interface with NumPy#
|
Method to cast NumPy universal functions directly on Raster classes, by passing to the masked array. |
|
Method to cast NumPy array function directly on a Raster object by applying it to the masked array. |
SatelliteImage#
Examples using geoutils.SatelliteImage
#
Opening a file#
|
Satellite image metadata#
Mask#
Examples using geoutils.Mask
#
Opening a file#
|
The georeferenced mask. |
Overloaded Raster methods#
|
Crop the raster to a given extent. |
|
Reproject raster to a different geotransform (resolution, bounds) and/or coordinate reference system (CRS). |
|
Polygonize the raster into a vector. |
|
Compute proximity distances to the raster target pixels, or to a vector geometry on the raster grid. |
Multiple rasters#
|
Stack a list of rasters on their maximum extent into a multi-band raster. |
|
Spatially merge a list of rasters into one larger raster of their maximum extent. |
Vector#
Examples using geoutils.Vector
#
Metric buffer and without overlap
Opening a file#
|
The georeferenced vector |
Summarize information about the vector. |
Unique attributes#
Geodataframe of the vector. |
|
Coordinate reference system of the vector. |
|
Total bounding box of the vector. |
|
Name on disk, if it exists. |
Caution
The bounds
attribute of a Vector
corresponds to the total_bounds
attribute of a
GeoDataFrame
, for consistency between rasters and vectors (and can also be accessed through total_bounds
).
The equivalent of geopandas.GeoDataFrame.bounds
(i.e., a per-feature bounds) for Vectors
is geom_bounds
.
Geospatial handling methods#
|
Crop the vector to given extent. |
|
Reproject vector to a specified coordinate reference system. |
|
Rasterize vector to a raster or mask, with input geometries burned in. |
|
Compute proximity distances to this vector's geometry. |
Plotting#
|
Plot the vector. |
Create mask#
|
Create a mask from the vector features. |
Geometry manipulation#
|
Buffer the vector features in a local metric system (UTM or UPS). |
|
Buffer the vector geometries without overlapping each other. |
Projection tools#
|
Get local metric coordinate reference system for the vector (UTM, UPS, or custom Mercator or Polar). |
|
Create a vector polygon from projected bounds of a raster or vector. |
|
Get vector bounds projected in a specified CRS. |
|
Get vector footprint projected in a specified CRS. |
Indexing#
|
Index the geodataframe. |
From Shapely and GeoPandas#
Geometric attributes and methods#
This first category of attributes and methods return a geometric output converted to a Vector
by default.
Attributes:
Returns a |
|
Returns a geometry containing the union of all geometries in the |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
Methods:
Returns a |
|
Returns a |
|
Repairs invalid geometries. |
|
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Return a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Returns a |
|
Dissolve geometries within groupby into single observation. |
|
Explode multi-part geometries into multiple single geometries. |
|
Spatial join of two Vectors. |
|
Spatial join of two Vectors based on the distance between their geometries. |
|
Perform spatial overlay between Vectors. |
|
Clip points, lines, or polygon geometries to the mask extent. |
|
Transform geometries to a new coordinate reference system. |
|
Set the Coordinate Reference System (CRS) of the |
|
Set the Vector geometry using either an existing column or the specified input. |
|
Renames the Vector geometry column to the specified name. |
Coordinate based indexer to select by intersection with bounding box. |
Non-geometric per-feature attributes and methods#
This second category of attributes and methods return a non-geometric output with same length as the number of features. They are thus appended in the
dataframe of the current Vector
by default, using as column name the name of the operation (e.g., “area”, “contains” or “intersects”).
Otherwise, calling the method from Vector.ds
, they return a pandas.Series
as in GeoPandas.
Attributes:
Returns or appends to |
|
Returns or appends to |
|
Returns or appends to |
|
Returns a |
|
Returns or appends to |
|
Returns or appends to |
|
Returns a |
|
Returns or appends to |
|
Returns or appends to |
|
Returns or appends to |
Methods:
|
Returns or appends to |
|
Returns or appends to |
|
Returns or appends to |
|
Returns or appends to |
|
Returns or appends to |
|
Returns or appends to |
|
Returns True for all aligned geometries that overlap other, else False. |
|
Returns or appends to |
|
Returns or appends to |
|
Returns a |
|
Returns a |
|
Returns or appends to |
I/O, conversions and others#
Important
The behaviour of methods below is not modified in Vector
, as they deal with outputs of different types.
To ensure those are up-to-date with GeoPandas, alternatively call those from Vector.ds
.
|
Alternate constructor to create a |
|
Alternate constructor to create Vector from an iterable of features or a feature collection. |
|
Alternate constructor to create a |
|
Construct Vector from dict of array-like or dicts by overriding DataFrame.from_dict method with geometry and crs |
|
Write the |
|
Write a Vector to the Feather format. |
|
Write a Vector to the Parquet format. |
|
Encode all geometry columns in the Vector to WKT. |
|
Encode all geometry columns in the Vector to WKB. |
|
Returns a GeoJSON representation of the |
|
Upload Vector into PostGIS database. |
|
Write object to a comma-separated values (csv) file. |
Other attributes and methods#
Check the existence of the spatial index without generating it. |
|
Generate the spatial index |
|
Total bounds of the vector. |
See also
The methods above are described in GeoPandas GeoSeries’s API and Shapely object’s documentation.