geoutils.Vector#
- class geoutils.Vector(filename_or_dataset)[source]#
The georeferenced vector.
- Main attributes:
- ds:
geopandas.GeoDataFrame Geodataframe of the vector.
- crs:
pyproj.crs.CRS Coordinate reference system of the vector.
- bounds:
rio.coords.BoundingBox Coordinate bounds of the vector.
- ds:
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)[source]#
Instantiate a vector from either a filename, a GeoPandas dataframe or series, or a Shapely geometry.
Methods
__init__(filename_or_dataset)Instantiate a vector from either a filename, a GeoPandas dataframe or series, or a Shapely geometry.
affine_transform(matrix)Return a
Vectorwith translated geometries.buffer(distance[, resolution, cap_style, ...])Return a
Vectorof geometries representing all points within a givendistanceof 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
Vectorof the portions of geometry within the given rectangle.concave_hull([ratio, allow_holes])Return a
Vectorof geometries representing the concave hull of vertices of each geometry.contains(other[, align])Return a
Seriesofdtype('bool')with valueTruefor each aligned geometry that contains other.contains_properly(other[, align])Return a
Seriesofdtype('bool')with valueTruefor each aligned geometry that is completely insideother, with no common boundary points.copy()Return a copy of the vector.
Return a
Seriescontaining the count of the number of coordinate pairs in each geometry.Return a
Seriescontaining the count of geometries in each multi-part geometry.Return a
Seriescontaining the count of the number of interior rings in a polygonal geometry.covered_by(other[, align])Return a
Seriesofdtype('bool')with valueTruefor each aligned geometry that is entirely covered by other.covers(other[, align])Return a
Seriesofdtype('bool')with valueTruefor 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
Seriesofdtype('bool')with valueTruefor each aligned geometry that cross other.cx()Coordinate based indexer to select by intersection with bounding box.
delaunay_triangles([tolerance, only_edges])Return a
Vectorconsisting of objects representing the computed Delaunay triangulation between the vertices of an input geometry.difference(other[, align])Return a
Vectorof the points in each aligned geometry that are not in other.disjoint(other[, align])Return a
Seriesofdtype('bool')with valueTruefor each aligned geometry disjoint to other.dissolve([by, aggfunc, as_index, level, ...])Dissolve geometries within groupby into single observation.
distance(other[, align])Return a
Seriescontaining the distance to aligned other.dwithin(other, distance[, align])Return a
Seriesofdtype('bool')with valueTruefor each aligned geometry that is within a set distance fromother.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.
Return a
Vectorof 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
Seriescontaining the Frechet distance to aligned other.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
Vectorfrom a file.from_postgis(sql, con[, geom_col, crs, ...])Alternate constructor to create a
Vectorfrom a sql query containing a geometry column in WKB representation.geom_equals(other[, align])Return a
Seriesofdtype('bool')with valueTruefor 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.
get_bounds_projected(out_crs[, densify_points])Get vector bounds projected in a specified CRS.
get_coordinates([include_z, ignore_index, ...])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).
Return a
Seriesof the precision of each geometry.hausdorff_distance(other[, align, densify])Return a
Seriescontaining 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
Vectorof the intersection of points in each aligned geometry with other.Return a geometry containing the intersection of all geometries in the
Vector.intersects(other[, align])Return a
Seriesofdtype('bool')with valueTruefor each aligned geometry that intersects other.Return a
Seriesof 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.
Repairs invalid geometries.
Return a
Vectorof geometries representing the minimum bounding circle that encloses each geometry.Return a Series of the radii of the minimum bounding circles that enclose each geometry.
Return a
Seriescontaining the minimum clearance distance, which is the smallest distance by which a vertex of the geometry could be moved to produce an invalid geometry.Return a
Vectorof the general minimum bounding rectangle that contains the object.Return a
Vectorof normalized geometries to normal form (or canonical form).offset_curve(distance[, quad_segs, ...])Return a
LineStringorMultiLineStringgeometry 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([ref_crs, cmap, vmin, vmax, alpha, ...])Plot the vector.
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
Vectorcontaining a copy of the input geometry with repeated points removed.rename_geometry(col[, inplace])Rename the Vector geometry column to the specified name.
Return a
Vectorof (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
Vectorwith the order of coordinates reversed.rotate(angle[, origin, use_radians])Return a
Vectorwith rotated geometries.save(filename[, driver, schema, index])Write the vector to file.
scale([xfact, yfact, zfact, origin])Return a
Vectorwith scaled geometries.segmentize(max_segment_length)Return a
Vectorwith 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_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
GeoSerieswith 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
Vectorcontaining 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
Vectorwith skewed geometries.snap(other, tolerance[, align])Snap the vertices and segments of the geometry to vertices of the reference.
symmetric_difference(other[, align])Return a
Vectorof the symmetric difference of points in each aligned geometry with other.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
Vectorto 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
Vectoras a string.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_wkb([hex])Encode all geometry columns in the Vector to WKB.
to_wkt(**kwargs)Encode all geometry columns in the Vector to WKT.
touches(other[, align])Return a
Seriesofdtype('bool')with valueTruefor each aligned geometry that touches other.transform(transformation[, include_z])Return a
Vectorwith 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
Vectorof 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
Vectorconsisting of objects representing the computed Voronoi diagram around the vertices of an input geometry.within(other[, align])Return a
Seriesofdtype('bool')with valueTruefor each aligned geometry that is within other.Attributes
active_geometry_nameReturn a
Seriescontaining the area of each geometry in theVectorexpressed in the units of the CRS.Return a
Vectorof lower dimensional objects representing each geometry's set-theoretic boundary.Total bounding box of the vector.
Return a
Vectorof points representing the centroid of each geometry.columnsReturn a
Vectorof geometries representing the convex hull of each geometry.Coordinate reference system of the vector.
Geodataframe of the vector.
Return a
Vectorof geometries representing the envelope of each geometry.Return a
Vectorof LinearRings representing the outer boundary of each polygon in the Vector.footprintFootprint of the raster.
Returns or appends to
VectoraSerieswith the bounds of each geometry feature.Returns a
Seriesof strings specifying the Geometry Type of each object.geometryCheck the existence of the spatial index without generating it.
Return a
Seriesofdtype('bool')with valueTruefor features that have a z-component.indexReturn a
Seriesof List representing the inner rings of each polygon in the Vector.Return a
Seriesofdtype('bool')with valueTrueif a LineString or LinearRing is counterclockwise.Return a
Seriesofdtype('bool')with valueTrueif a LineString's or LinearRing's first and last points are equal.Returns a
Seriesofdtype('bool')with valueTruefor empty geometries.Return a
Seriesofdtype('bool')with valueTruefor features that are closed.Return a
Seriesofdtype('bool')with valueTruefor geometries that do not cross themselves.Return a
Seriesofdtype('bool')with valueTruefor geometries that are valid.Return a
Seriescontaining the length of each geometry expressed in the units of the CRS.Name on disk, if it exists.
Generate the spatial index.
Total bounds of the vector.