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. |
Main attributes#
Array of the raster. |
|
Coordinate reference system of the raster. |
|
Geotransform of the raster. |
|
Nodata value of the raster. |
|
Pixel interpretation 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. |
|
Band indexes loaded in memory if they are, otherwise on disk. |
|
Resolution (X, Y) of the raster in georeferenced units. |
|
Bounding coordinates of the raster. |
|
Data type of the raster (string representation). |
Other attributes#
Whether the raster array is a boolean data type (a mask). |
|
Count of bands on disk if it exists. |
|
Band indexes on disk if a file exists. |
|
Whether the raster array is loaded. |
|
Whether the array has been modified since it was loaded from disk. |
|
Name of the raster file on disk, if it exists. |
|
Driver used to read a file on disk. |
|
Metadata tags of the raster. |
Geospatial handling methods#
|
Crop the raster to a given extent. |
|
Crop raster based on pixel indices (bbox), converting them into georeferenced coordinates. |
|
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. |
|
Interpolate raster values at a set of points. |
|
Reduce raster values around point coordinates. |
|
Apply a filter to the array. |
Plotting#
|
Plot the raster, with axes in projection of image. |
Get statistics#
|
Retrieve specified statistics or all available statistics for the raster data. |
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. |
|
Create a raster from a point cloud with coordinates on a regular grid. |
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. |
|
Translate 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 operators casting to mask (boolean raster)#
|
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. |
Multiple rasters#
|
Function to load multiple rasters at once in a memory efficient way. |
|
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#
Opening a file#
|
The georeferenced vector. |
|
Summarize information about the vector. |
Main 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 raster or point cloud mask from the vector features (True if pixel/point contained by any vector feature, False if not). |
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:
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
Methods:
Return a |
|
Return a |
|
Repairs invalid geometries. |
|
|
Return a |
|
Return a |
|
Return a |
|
Return a geometry containing the union of all geometries in the |
|
Return a |
Return a geometry containing the intersection of all geometries in the |
|
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Shift a vector by a (x,y) offset, and optionally a z offset. |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
Return a |
|
Return a |
|
Return a |
|
|
Return a |
|
Return a |
Return a |
|
|
Return a |
|
Create polygons formed from the linework of a Vector. |
|
Return a |
Force the dimensionality of a geometry to 2D. |
|
|
Force the dimensionality of a geometry to 3D. |
|
Return (Multi)LineStrings formed by combining the lines in a MultiLineString. |
|
Return the shortest two-point line between two geometries. |
|
Return a point at the specified distance along each geometry. |
|
Return the shared paths between two geometries. |
|
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. |
|
Snap the vertices and segments of the geometry to vertices of the reference. |
|
Transform geometries to a new coordinate reference system. |
|
Set the Coordinate Reference System (CRS) of the |
|
Return the n-th geometry from a collection of geometries. |
|
Set the Vector geometry using either an existing column or the specified input. |
|
Rename the Vector geometry column to the specified name. |
|
Return a |
Return a |
|
|
|
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:
Return a |
|
Return a |
|
Return a |
|
Returns a |
|
Returns or appends to |
|
Return a |
|
Returns a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
Methods:
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return True for all aligned geometries that overlap other, else False. |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Return a Series of the radii of the minimum bounding circles that enclose each geometry. |
|
|
Return a |
|
Return a |
|
Return a |
|
Return a |
|
Calculate the distance along a Hilbert curve. |
|
Return the DE-9IM intersection matrices for the geometries. |
|
Return True if the DE-9IM string code for the relationship between the geometries satisfies the pattern, else False. |
|
Return the distance along each geometry nearest to other. |
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. |
|
Construct a Vector from an Arrow table object based on GeoArrow extension types. |
|
Write the |
|
Write a Vector to the Feather format. |
|
Write a Vector to the Parquet format. |
|
Encode a Vector to GeoArrow format. |
|
Encode all geometry columns in the Vector to WKT. |
|
Encode all geometry columns in the Vector to WKB. |
|
Return a GeoJSON representation of the |
|
Upload Vector into PostGIS database. |
|
Return a python feature collection representation of the Vector as a dictionary with a list of features based on the |
|
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.
Point cloud#
Examples using geoutils.PointCloud#
Opening a file#
|
The georeferenced point cloud. |
|
Summarize information about the vector. |
Main attributes#
Geodataframe of the point cloud. |
|
Name of data column of the point cloud. |
|
Data of the point cloud. |
|
Coordinate reference system of the vector. |
Other attributes#
Number of points in the point cloud. |
Create and convert from data#
|
Create point cloud from three 1D array-like coordinates for X/Y/Z. |
|
Create point cloud from a 3 x N or N x 3 array of X coordinates, Y coordinates and Z values. |
|
Create point cloud from an iterable of 3-tuples (X coordinate, Y coordinate, Z value). |
Convert point cloud to three 1D arrays of coordinates for X/Y/Z. |
|
Convert point cloud to a 3 x N array of X coordinates, Y coordinates and Z values. |
|
Convert point cloud to a list of 3-tuples (X coordinate, Y coordinate, Z value). |
Geospatial#
|
Crop the vector to given extent. |
|
Reproject vector to a specified coordinate reference system. |
|
Shift a vector by a (x,y) offset, and optionally a z offset. |
Interface with raster#
|
Grid point cloud into a raster. |
Statistics#
|
Retrieve specified statistics or all available statistics for the point cloud data. |
|
Randomly sample the point cloud. |
Testing methods#
|
Check if two point clouds are equal. |
Check that point cloud X/Y coordinates and CRS are equal. |