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 API#
GeoUtils exposes the raster API through two mirrored interfaces:
Raster, an interface operating directly on a GeoUtils object,A
rstaccessor extendingxarray.DataArrayobjects as rasters.
Both expose the same methods and attributes.
Only file opening and scalable execution differ between the two interfaces:
File opening:
Rasterobjects are opened by instantiating the class, whereasopen_raster()is used for anxarray.DataArrayobject,Scalable execution: the
rstaccessor supports Dask, while theRastersupports Multiprocessing instead.
Opening a raster file#
Use open_raster() for an xarray.DataArray, or instantiate for a Raster.
|
Open a raster using Rioxarray, always masked and squeezed. |
|
Instantiate a raster from a filename or rasterio dataset. |
Create raster from an array#
|
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. |
|
Footprint of the raster. |
|
Data type of the raster. |
Other attributes#
Geospatial operations#
|
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 of polygon geometries delineating target values. |
|
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#
Statistics#
|
Calculate summary statistics or statistics grouped by categories, bins, or vector zones. |
Data manipulation#
|
Copy the raster in-memory. |
|
Set a new nodata value for all bands. |
|
Get NaN array from the raster. |
|
Randomly sample valid raster values allowed by mask, without replacement. |
Loading, writing and converting#
|
|
|
Convert raster to point cloud. |
|
Create a raster from a point cloud with coordinates on a regular grid. |
Georeferencing utilities#
|
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 bounds of the raster. |
Projection utilities#
|
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 raster and another. |
Testing utilities#
|
Check if two rasters are equal. |
|
Check that raster shape, geotransform and CRS are equal. |
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. |
Geometry manipulation#
|
Buffer the vector features in a local metric system. |
|
Buffer the vector geometries without overlapping each other. |
Projection tools#
|
Get local metric coordinate reference system for the vector. |
|
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 coordinate 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. |
|
Print summary information about the point cloud. |
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 a point cloud from separate X, Y and Z arrays. |
|
Create a point cloud from a 3 x N or N x 3 array of X, Y and Z values. |
|
Create a point cloud from an iterable of X, Y and Z tuples. |
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. |
Geospatial#
|
Crop the vector to given extent. |
|
Reproject point coordinates, preserving their order and value columns. |
|
Shift a vector by a coordinate offset. |
Interface with raster#
|
Grid the point cloud into a raster. |
Statistics#
|
Calculate summary statistics or statistics grouped by categories, bins, or vector zones. |
|
Randomly sample finite point cloud values allowed by mask, without replacement. |
Testing methods#
|
Check if two point clouds are equal. |
|
Check that point-cloud X/Y coordinates and CRS are equal. |
Multiprocessing configuration#
To perform chunked execution on GeoUtils objects, pass this Multiprocessing configuration to function that support it.
|
Configuration class for handling multiprocessing parameters in raster and point cloud processing. |