⚠️ Our 0.1 release refactored several early-development functions for long-term stability, to update your code see here. ⚠️
Future changes will come with deprecation warnings! 🙂

geoutils.Vector

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.

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.

Parameters:

filename_or_dataset (str | Path | GeoDataFrame | GeoSeries | BaseGeometry) – Path to file, or GeoPandas dataframe or series, or 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 Vector with translated geometries.

buffer(distance[, resolution])

Returns 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.

clip(mask[, keep_geom_type])

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

clip_by_rect(xmin, ymin, xmax, ymax)

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

contains(other[, align])

Returns or appends to Vector a Series of dtype('bool') with value True for each aligned geometry that contains other.

copy()

Return a copy of the vector.

covered_by(other[, align])

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

covers(other[, align])

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

create_mask([raster, crs, xres, yres, ...])

Create a mask from the vector features.

crop(crop_geom[, clip, inplace])

Crop the vector to given extent.

crosses(other[, align])

Returns or appends to Vector 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.

difference(other[, align])

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

disjoint(other[, align])

Returns or appends to Vector 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])

Returns or appends to Vector a Series containing the distance to aligned other.

estimate_utm_crs([datum_name])

Returns 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.

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.

geom_almost_equals(other[, decimal, align])

Returns or appends to Vector a Series of dtype('bool') with value True if each aligned geometry is approximately equal to other.

geom_equals(other[, align])

Returns or appends to Vector 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.

get_bounds_projected(out_crs[, densify_points])

Get vector bounds projected in a specified CRS.

get_footprint_projected(out_crs[, ...])

Get vector footprint projected in a specified CRS.

get_metric_crs([local_crs_type, method])

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

info()

Summarize information about the vector.

intersection(other[, align])

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

intersects(other[, align])

Returns or appends to Vector a Series of dtype('bool') with value True for each aligned geometry that intersects other.

iterfeatures([na, show_bbox, drop_id])

Returns an iterator that yields feature dictionaries that comply with __geo_interface__

make_valid()

Repairs invalid geometries.

normalize()

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

overlaps(other[, align])

Returns 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.

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.

rename_geometry(col[, inplace])

Renames the Vector geometry column to the specified name.

representative_point()

Returns 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.

rotate(angle[, origin, use_radians])

Returns a Vector with rotated geometries.

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

Write the vector to file.

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

Returns a Vector with scaled geometries.

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.

simplify(*args, **kwargs)

Returns 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])

Returns a Vector with skewed geometries.

symmetric_difference(other[, align])

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

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_json([na, show_bbox, drop_id])

Returns a GeoJSON representation of the Vector as 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])

Returns or appends to Vector a Series of dtype('bool') with value True for each aligned geometry that touches other.

translate([xoff, yoff, zoff])

Returns a Vector with translated geometries.

union(other[, align])

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

vector_equal(other, **kwargs)

Check if two vectors are equal.

within(other[, align])

Returns or appends to Vector a Series of dtype('bool') with value True for each aligned geometry that is within other.

Attributes

area

Returns or appends to Vector a Series containing the area of each geometry in the Vector expressed in the units of the CRS.

boundary

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

bounds

Total bounding box of the vector.

centroid

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

convex_hull

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

crs

Coordinate reference system of the vector.

ds

Geodataframe of the vector.

envelope

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

exterior

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

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

Returns or appends to Vector a Series of dtype('bool') with value True for features that have a z-component.

index

interiors

Returns or appends to Vector a Series of List representing the inner rings of each polygon in the Vector.

is_empty

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

is_ring

Returns or appends to Vector a Series of dtype('bool') with value True for features that are closed.

is_simple

Returns or appends to Vector a Series of dtype('bool') with value True for geometries that do not cross themselves.

is_valid

Returns or appends to Vector a Series of dtype('bool') with value True for geometries that are valid.

length

Returns or appends to Vector a Series containing the length of each geometry expressed in the units of the CRS.

name

Name on disk, if it exists.

sindex

Generate the spatial index

total_bounds

Total bounds of the vector.

unary_union

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