leiap.spatial¶
This file contains functions related to spatial data operations
Functions
find_geo_field (df, fields_shp_path) |
Find the identifier for the field where the point or artifact lies geographically. |
find_artifact_coords (artifacts, points[, …]) |
Add Easting and Northing to artifacts |
read_fields_shp (path) |
Load and clean up the Survey_Fields_Master.shp file |
convert_coordinates (df[, x_col, y_col, …]) |
Transform coordinates from one system to another |
-
leiap.spatial.
find_geo_field
(df, fields_shp_path)[source]¶ Find the identifier for the field where the point or artifact lies geographically.
Parameters: - df (pandas DataFrame) – Points or Artifacts DataFrame; must contain ‘Easting’ and ‘Northing’ columns
- fields_shp_path (str) – Path to the shapefile (.shp) containing the fields
Returns: joined_df – Identical to the input points DataFrame with an added ‘geo_field’ column
Return type: pandas DataFrame
Notes
-
leiap.spatial.
find_artifact_coords
(artifacts, points, join_col='SurveyPointId')[source]¶ Add Easting and Northing to artifacts
Parameters: - artifacts (pandas DataFrame) – DataFrame of artifact records
- points (pandas DataFrame) – DataFrame of points; must have ‘Easting’, ‘Northing’, and <join_col> columns
- join_col (str) – Column on which to join artifacts and points
Returns: artifacts – Identical to artifacts input DataFrame with ‘Easting’, ‘Northing’ columns added
Return type: pandas DataFrame
-
leiap.spatial.
read_fields_shp
(path)[source]¶ Load and clean up the Survey_Fields_Master.shp file
Notes
Not meant to be a generic load function! Designed to work specifically with the file we have been using.
-
leiap.spatial.
convert_coordinates
(df, x_col='Easting', y_col='Northing', from_epsg='32631', to_epsg='3857')[source]¶ Transform coordinates from one system to another
Parameters: - df (pandas DataFrame) – Points or artifacts DataFrame with coordinate columns
- y_col (x_col,) – Columns with x- and y-coordinates
- to_epsg (from_epsg,) – EPSG coordinate system codes for the input and output coordinates
Returns: df – Original DataFrame with new columns ‘x2’ and ‘y2’
Return type: pandas DataFrame
Notes
Default behavior is to convert UTMs from Zone 31N to Web Mercator