gemgis.vector.extract_xy_points
gemgis.vector.extract_xy_points#
- gemgis.vector.extract_xy_points(gdf: geopandas.geodataframe.GeoDataFrame, reset_index: bool = True, drop_id: bool = True, drop_index: bool = True, overwrite_xy: bool = False, target_crs: Union[str, pyproj.crs.crs.CRS] = None, bbox: Optional[Sequence[float]] = None) geopandas.geodataframe.GeoDataFrame #
Extracting X and Y coordinates from a GeoDataFrame (Points) and returning a GeoDataFrame with X and Y coordinates as additional columns
- Parameters
gdf (gpd.geodataframe.GeoDataFrame) – GeoDataFrame created from vector data containing elements of geom_type Point
reset_index (bool) – Variable to reset the index of the resulting GeoDataFrame. Options include:
True
orFalse
, default set toTrue
drop_id (bool) – Variable to drop the id column. Options include:
True
orFalse
, default set toTrue
drop_index (bool) – Variable to drop the index column. Options include:
True
orFalse
, default set toTrue
overwrite_xy (bool) – Variable to overwrite existing X and Y values. Options include:
True
orFalse
, default set toFalse
target_crs (Union[str, pyproj.crs.crs.CRS]) – Name of the CRS provided to reproject coordinates of the GeoDataFrame, e.g.
target_crs='EPSG:4647'
bbox (list) – Values (minx, maxx, miny, maxy) to limit the extent of the data, e.g.
bbox=[0, 972, 0, 1069]
- Returns
gdf – GeoDataFrame with appended X and Y coordinates as new columns and optional columns
- Return type
gpd.geodataframe.GeoDataFrame
New in version 1.0.x.
Example
>>> # Loading Libraries and File >>> import gemgis as gg >>> import geopandas as gpd >>> gdf = gpd.read_file(filename='file.shp') >>> gdf id formation geometry 0 None Ton POINT (19.150 293.313) 1 None Ton POINT (61.934 381.459) 2 None Ton POINT (109.358 480.946) 3 None Ton POINT (157.812 615.999) 4 None Ton POINT (191.318 719.094)
>>> # Extracting X and Y Coordinates from Point Objects >>> gdf_xy = gg.vector.extract_xy_points(gdf=gdf, reset_index=False) >>> gdf_xy formation geometry X Y 0 Ton POINT (19.150 293.313) 19.15 293.31 1 Ton POINT (61.934 381.459) 61.93 381.46 2 Ton POINT (109.358 480.946) 109.36 480.95 3 Ton POINT (157.812 615.999) 157.81 616.00 4 Ton POINT (191.318 719.094) 191.32 719.09
See also
extract_xy_linestring
Extracting X and Y coordinates from a GeoDataFrame containing Shapely LineStrings and saving the X and Y coordinates as lists for each LineString
extract_xy_linestrings
Extracting X and Y coordinates from a GeoDataFrame containing Shapely LineStrings
extract_xy
Extracting X and Y coordinates from Vector Data