Skip to content

Reproject vector

reproject_vector(geodataframe, target_crs)

Reprojects vector data to match given coordinate reference system (EPSG).

Parameters:

Name Type Description Default
geodataframe GeoDataFrame

The vector dataframe to be reprojected.

required
target_crs int

Target CRS as an EPSG code.

required

Returns:

Type Description
GeoDataFrame

Reprojected vector data.

Source code in eis_toolkit/vector_processing/reproject_vector.py
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
@beartype
def reproject_vector(geodataframe: geopandas.GeoDataFrame, target_crs: int) -> geopandas.GeoDataFrame:
    """Reprojects vector data to match given coordinate reference system (EPSG).

    Args:
        geodataframe: The vector dataframe to be reprojected.
        target_crs: Target CRS as an EPSG code.

    Returns:
        Reprojected vector data.
    """

    if geodataframe.crs.to_epsg() == target_crs:
        raise MatchingCrsException("Vector data is already in the target CRS.")

    reprojected_gdf = geodataframe.to_crs("epsg:" + str(target_crs))
    return reprojected_gdf