geoutils.PointCloud

geoutils.PointCloud#

class geoutils.PointCloud(filename_or_dataset, data_column=None)[source]#

The georeferenced point cloud.

A point cloud is a vector of 2D point geometries associated to numeric values from a main data column, and can also contain auxiliary data columns.

Main attributes:
ds: geopandas.GeoDataFrame

Geodataframe of the point cloud.

data_column: str

Name of point cloud data column.

crs: pyproj.crs.CRS

Coordinate reference system of the point cloud.

bounds: rio.coords.BoundingBox

Coordinate bounds of the point cloud.

All other attributes are derivatives of those attributes, or read from the file on disk. See the API for more details.

__init__(filename_or_dataset, data_column=None)[source]#

Instantiate a point cloud from either a data column name and a vector (filename, GeoPandas dataframe or series, or a Shapely geometry), or only with a point cloud file type.

Parameters:
  • filename_or_dataset (str | Path | GeoDataFrame | GeoSeries | BaseGeometry) – Path to vector file, or GeoPandas dataframe or series, or Shapely geometry.

  • data_column (str | None) – Name of main data column defining the point cloud (not required for LAS/LAZ formats).

Methods

__init__(filename_or_dataset[, data_column])

Instantiate a point cloud from either a data column name and a vector (filename, GeoPandas dataframe or series, or a Shapely geometry), or only with a point cloud file type.

affine_transform(matrix)

Return a Vector with translated geometries.

astype(dtype[, convert_coords, inplace])

Convert data type of the point cloud data column.

buffer(distance[, resolution, cap_style, ...])

Return a Vector of geometries representing all points within a given distance of each geometric object.

buffer_metric(buffer_size)

Buffer the vector features in a local metric system (UTM or UPS).

buffer_without_overlap(buffer_size[, ...])

Buffer the vector geometries without overlapping each other.

build_area([node])

Create an areal geometry formed by the constituent linework.

clip(mask[, keep_geom_type, sort])

Clip points, lines, or polygon geometries to the mask extent.

clip_by_rect(xmin, ymin, xmax, ymax)

Return a Vector of the portions of geometry within the given rectangle.

columns()

concave_hull([ratio, allow_holes])

Return a Vector of geometries representing the concave hull of vertices of each geometry.

contains(other[, align])

Return a Series of dtype('bool') with value True for each aligned geometry that contains other.

contains_properly(other[, align])

Return a Series of dtype('bool') with value True for each aligned geometry that is completely inside other, with no common boundary points.

copy([new_array])

Copy the point cloud in-memory.

count_coordinates()

Return a Series containing the count of the number of coordinate pairs in each geometry.

count_geometries()

Return a Series containing the count of geometries in each multi-part geometry.

count_interior_rings()

Return a Series containing the count of the number of interior rings in a polygonal geometry.

covered_by(other[, align])

Return a Series of dtype('bool') with value True for each aligned geometry that is entirely covered by other.

covers(other[, align])

Return a Series of dtype('bool') with value True for each aligned geometry that is entirely covering other.

create_mask([ref, crs, res, bounds, points, ...])

Create a raster or point cloud mask from the vector features (True if pixel/point contained by any vector feature, False if not).

crop(crop_geom[, clip, inplace])

Crop the vector to given extent.

crosses(other[, align])

Return a Series of dtype('bool') with value True for each aligned geometry that cross other.

cx()

Coordinate based indexer to select by intersection with bounding box.

delaunay_triangles([tolerance, only_edges])

Return a Vector consisting of objects representing the computed Delaunay triangulation between the vertices of an input geometry.

difference(other[, align])

Return a Vector of the points in each aligned geometry that are not in other.

disjoint(other[, align])

Return a Series of dtype('bool') with value True for each aligned geometry disjoint to other.

dissolve([by, aggfunc, as_index, level, ...])

Dissolve geometries within groupby into single observation.

distance(other[, align])

Return a Series containing the distance to aligned other.

dwithin(other, distance[, align])

Return a Series of dtype('bool') with value True for each aligned geometry that is within a set distance from other.

estimate_utm_crs([datum_name])

Return the estimated UTM CRS based on the bounds of the dataset.

explode([column, ignore_index, index_parts])

Explode multi-part geometries into multiple single geometries.

extract_unique_points()

Return a Vector of MultiPoints representing all distinct vertices of an input geometry.

force_2d()

Force the dimensionality of a geometry to 2D.

force_3d([z])

Force the dimensionality of a geometry to 3D.

frechet_distance(other[, align, densify])

Return a Series containing the Frechet distance to aligned other.

from_array(data, crs[, data_column, use_z])

Create point cloud from a 3 x N or N x 3 array of X coordinates, Y coordinates and Z values.

from_arrow(table[, geometry])

Construct a Vector from an Arrow table object based on GeoArrow extension types.

from_bounds_projected(raster_or_vector[, ...])

Create a vector polygon from projected bounds of a raster or vector.

from_dict(data[, geometry, crs])

Construct Vector from dict of array-like or dicts by overriding DataFrame.from_dict method with geometry and crs.

from_features(features, crs, columns)

Alternate constructor to create Vector from an iterable of features or a feature collection.

from_file(filename, **kwargs)

Alternate constructor to create a Vector from a file.

from_postgis(sql, con[, geom_col, crs, ...])

Alternate constructor to create a Vector from a sql query containing a geometry column in WKB representation.

from_tuples(tuples_xyz, crs[, data_column, ...])

Create point cloud from an iterable of 3-tuples (X coordinate, Y coordinate, Z value).

from_xyz(x, y, z, crs[, data_column, use_z])

Create point cloud from three 1D array-like coordinates for X/Y/Z.

geom_equals(other[, align])

Return a Series of dtype('bool') with value True for each aligned geometry equal to other.

geom_equals_exact(other, tolerance[, align])

Return True for all geometries that equal aligned other to a given tolerance, else False.

georeferenced_coords_equal(pc)

Check that point cloud X/Y coordinates and CRS are equal.

get_bounds_projected(out_crs[, densify_points])

Get vector bounds projected in a specified CRS.

get_coordinates([include_z, ignore_index, ...])

Get coordinates from a Vector as a DataFrame of floats.

get_footprint_projected(out_crs[, ...])

Get vector footprint projected in a specified CRS.

get_geometry(index)

Return the n-th geometry from a collection of geometries.

get_metric_crs([local_crs_type, method])

Get local metric coordinate reference system for the vector (UTM, UPS, or custom Mercator or Polar).

get_precision()

Return a Series of the precision of each geometry.

get_stats([stats_name])

Retrieve specified statistics or all available statistics for the point cloud data.

grid([ref, grid_coords, res, resampling, ...])

Grid point cloud into a raster.

hausdorff_distance(other[, align, densify])

Return a Series containing the Hausdorff distance to aligned other.

hilbert_distance([total_bounds, level])

Calculate the distance along a Hilbert curve.

info([verbose])

Summarize information about the vector.

interpolate(distance[, normalized])

Return a point at the specified distance along each geometry.

intersection(other[, align])

Return a Vector of the intersection of points in each aligned geometry with other.

intersection_all()

Return a geometry containing the intersection of all geometries in the Vector.

intersects(other[, align])

Return a Series of dtype('bool') with value True for each aligned geometry that intersects other.

is_valid_reason()

Return a Series of strings with the reason for invalidity of each geometry.

iterfeatures([na, show_bbox, drop_id])

Return an iterator that yields feature dictionaries that comply with __geo_interface__.

line_merge([directed])

Return (Multi)LineStrings formed by combining the lines in a MultiLineString.

load([columns])

Load point cloud from disk (only supported for LAS files).

make_valid()

Repairs invalid geometries.

minimum_bounding_circle()

Return a Vector of geometries representing the minimum bounding circle that encloses each geometry.

minimum_bounding_radius()

Return a Series of the radii of the minimum bounding circles that enclose each geometry.

minimum_clearance()

Return a Series containing the minimum clearance distance, which is the smallest distance by which a vertex of the geometry could be moved to produce an invalid geometry.

minimum_rotated_rectangle()

Return a Vector of the general minimum bounding rectangle that contains the object.

normalize()

Return a Vector of normalized geometries to normal form (or canonical form).

offset_curve(distance[, quad_segs, ...])

Return a LineString or MultiLineString geometry at a distance from the object on its right or its left side.

overlaps(other[, align])

Return True for all aligned geometries that overlap other, else False.

overlay(right[, how, keep_geom_type, make_valid])

Perform spatial overlay between Vectors.

plot([column, ref_crs, cmap, vmin, vmax, ...])

Plot the point cloud.

pointcloud_equal(other, **kwargs)

Check if two point clouds are equal.

polygonize([node, full])

Create polygons formed from the linework of a Vector.

project(other[, normalized, align])

Return the distance along each geometry nearest to other.

proximity([raster, size, geometry_type, ...])

Compute proximity distances to this vector's geometry.

query(expression[, inplace])

Query the vector with a valid Pandas expression.

rasterize([raster, crs, xres, yres, bounds, ...])

Rasterize vector to a raster or mask, with input geometries burned in.

relate(other[, align])

Return the DE-9IM intersection matrices for the geometries.

relate_pattern(other, pattern[, align])

Return True if the DE-9IM string code for the relationship between the geometries satisfies the pattern, else False.

remove_repeated_points([tolerance])

Return a Vector containing a copy of the input geometry with repeated points removed.

rename_geometry(col[, inplace])

Rename the Vector geometry column to the specified name.

representative_point()

Return a Vector of (cheaply computed) points that are guaranteed to be within each geometry.

reproject([ref, crs, inplace])

Reproject vector to a specified coordinate reference system.

reverse()

Return a Vector with the order of coordinates reversed.

rotate(angle[, origin, use_radians])

Return a Vector with rotated geometries.

save(filename[, driver, schema, index])

Write the vector to file.

scale([xfact, yfact, zfact, origin])

Return a Vector with scaled geometries.

segmentize(max_segment_length)

Return a Vector with vertices added to line segments based on maximum segment length.

set_crs([crs, epsg, inplace, allow_override])

Set the Coordinate Reference System (CRS) of the Vector.

set_data_column(new_data_column)

Set new column as point cloud data column.

set_geometry(col[, drop, inplace, crs])

Set the Vector geometry using either an existing column or the specified input.

set_precision([grid_size, mode, inplace])

Return a GeoSeries with the precision set to a precision grid size.

shared_paths(other[, align])

Return the shared paths between two geometries.

shortest_line(other[, align])

Return the shortest two-point line between two geometries.

simplify(tolerance[, preserve_topology])

Return a Vector containing a simplified representation of each geometry.

sjoin(df, *args, **kwargs)

Spatial join of two Vectors.

sjoin_nearest(right[, how, max_distance, ...])

Spatial join of two Vectors based on the distance between their geometries.

skew([xs, ys, origin, use_radians])

Return a Vector with skewed geometries.

snap(other, tolerance[, align])

Snap the vertices and segments of the geometry to vertices of the reference.

subsample(subsample[, return_indices, ...])

Randomly sample the point cloud.

symmetric_difference(other[, align])

Return a Vector of the symmetric difference of points in each aligned geometry with other.

to_array()

Convert point cloud to a 3 x N array of X coordinates, Y coordinates and Z values.

to_arrow([index, geometry_encoding, ...])

Encode a Vector to GeoArrow format.

to_crs([crs, epsg, inplace])

Transform geometries to a new coordinate reference system.

to_csv([path_or_buf, sep, na_rep, ...])

Write object to a comma-separated values (csv) file.

to_feather(path[, index, compression, ...])

Write a Vector to the Feather format.

to_file(filename[, driver, schema, index])

Write the Vector to a file.

to_geo_dict([na, show_bbox, drop_id])

Return a python feature collection representation of the Vector as a dictionary with a list of features based on the __geo_interface__ GeoJSON-like specification.

to_json([na, show_bbox, drop_id])

Return a GeoJSON representation of the Vector as a string.

to_las(filename[, version, point_format, ...])

Write the point cloud to LAS/LAZ/COPC file.

to_parquet(path[, index, compression, ...])

Write a Vector to the Parquet format.

to_postgis(name, con[, schema, if_exists, ...])

Upload Vector into PostGIS database.

to_tuples()

Convert point cloud to a list of 3-tuples (X coordinate, Y coordinate, Z value).

to_wkb([hex])

Encode all geometry columns in the Vector to WKB.

to_wkt(**kwargs)

Encode all geometry columns in the Vector to WKT.

to_xyz()

Convert point cloud to three 1D arrays of coordinates for X/Y/Z.

touches(other[, align])

Return a Series of dtype('bool') with value True for each aligned geometry that touches other.

transform(transformation[, include_z])

Return a Vector with the transformation function applied to the geometry coordinates.

translate([xoff, yoff, zoff, inplace])

Shift a vector by a (x,y) offset, and optionally a z offset.

union(other[, align])

Return a Vector of the union of points in each aligned geometry with other.

union_all([method])

Return a geometry containing the union of all geometries in the Vector.

vector_equal(other, **kwargs)

Check if two vectors are equal.

voronoi_polygons([tolerance, extend_to, ...])

Return a Vector consisting of objects representing the computed Voronoi diagram around the vertices of an input geometry.

within(other[, align])

Return a Series of dtype('bool') with value True for each aligned geometry that is within other.

Attributes

active_geometry_name

area

Return a Series containing the area of each geometry in the Vector expressed in the units of the CRS.

boundary

Return a Vector of lower dimensional objects representing each geometry's set-theoretic boundary.

bounds

Total bounding box of the vector.

centroid

Return a Vector of points representing the centroid of each geometry.

convex_hull

Return a Vector of geometries representing the convex hull of each geometry.

crs

Coordinate reference system of the vector.

data

Data of the point cloud.

data_column

Name of data column of the point cloud.

ds

Geodataframe of the point cloud.

envelope

Return a Vector of geometries representing the envelope of each geometry.

exterior

Return a Vector of LinearRings representing the outer boundary of each polygon in the Vector.

footprint

Footprint of the raster.

geom_bounds

Returns or appends to Vector a Series with the bounds of each geometry feature.

geom_type

Returns a Series of strings specifying the Geometry Type of each object.

geometry

has_sindex

Check the existence of the spatial index without generating it.

has_z

Return a Series of dtype('bool') with value True for features that have a z-component.

index

interiors

Return a Series of List representing the inner rings of each polygon in the Vector.

is_ccw

Return a Series of dtype('bool') with value True if a LineString or LinearRing is counterclockwise.

is_closed

Return a Series of dtype('bool') with value True if a LineString's or LinearRing's first and last points are equal.

is_empty

Returns a Series of dtype('bool') with value True for empty geometries.

is_loaded

Whether the point cloud data is loaded.

is_mask

Whether the point cloud mask is a mask (boolean type).

is_ring

Return a Series of dtype('bool') with value True for features that are closed.

is_simple

Return a Series of dtype('bool') with value True for geometries that do not cross themselves.

is_valid

Return a Series of dtype('bool') with value True for geometries that are valid.

length

Return a Series containing the length of each geometry expressed in the units of the CRS.

name

Name on disk, if it exists.

point_count

Number of points in the point cloud.

sindex

Generate the spatial index.

total_bounds

Total bounds of the vector.