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.
- 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 givendistance
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
aSeries
ofdtype('bool')
with valueTrue
for each aligned geometry that contains other.copy
()Return a copy of the vector.
covered_by
(other[, align])Returns a
Series
ofdtype('bool')
with valueTrue
for each aligned geometry that is entirely covered by other.covers
(other[, align])Returns a
Series
ofdtype('bool')
with valueTrue
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
aSeries
ofdtype('bool')
with valueTrue
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
aSeries
ofdtype('bool')
with valueTrue
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
aSeries
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
aSeries
ofdtype('bool')
with valueTrue
if each aligned geometry is approximately equal to other.geom_equals
(other[, align])Returns or appends to
Vector
aSeries
ofdtype('bool')
with valueTrue
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
aSeries
ofdtype('bool')
with valueTrue
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__
Repairs invalid geometries.
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.
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
aSeries
ofdtype('bool')
with valueTrue
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
aSeries
ofdtype('bool')
with valueTrue
for each aligned geometry that is within other.Attributes
Returns or appends to
Vector
aSeries
containing the area of each geometry in theVector
expressed in the units of the CRS.Returns a
Vector
of lower dimensional objects representing each geometry's set-theoretic boundary.Total bounding box of the vector.
Returns a
Vector
of points representing the centroid of each geometry.Returns a
Vector
of geometries representing the convex hull of each geometry.Coordinate reference system of the vector.
Geodataframe of the vector.
Returns a
Vector
of geometries representing the envelope of each geometry.Returns a
Vector
of LinearRings representing the outer boundary of each polygon in the Vector.Returns or appends to
Vector
aSeries
with the bounds of each geometry feature.Returns a
Series
of strings specifying the Geometry Type of each object.geometry
Check the existence of the spatial index without generating it.
Returns or appends to
Vector
aSeries
ofdtype('bool')
with valueTrue
for features that have a z-component.index
Returns or appends to
Vector
aSeries
of List representing the inner rings of each polygon in the Vector.Returns a
Series
ofdtype('bool')
with valueTrue
for empty geometries.Returns or appends to
Vector
aSeries
ofdtype('bool')
with valueTrue
for features that are closed.Returns or appends to
Vector
aSeries
ofdtype('bool')
with valueTrue
for geometries that do not cross themselves.Returns or appends to
Vector
aSeries
ofdtype('bool')
with valueTrue
for geometries that are valid.Returns or appends to
Vector
aSeries
containing 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.
Returns a geometry containing the union of all geometries in the
Vector
.