environmentaltools.spatial.select_data

environmentaltools.spatial.select_data(data, corners)[source]

Select spatial data within specified rectangular boundaries.

Filters a DataFrame to include only points within the rectangular region defined by corner coordinates. Supports both dictionary and DataFrame corner specifications.

Parameters:
  • data (pd.DataFrame) – Spatial data containing at least ‘x’ and ‘y’ coordinate columns

  • corners (dict or pd.DataFrame) – Rectangular boundary definition. If dict, format should be: {‘x’: [xmin, xmax], ‘y’: [ymin, ymax]}. If DataFrame, should have ‘x’ and ‘y’ columns with [min, max] values.

Returns:

Filtered data containing only points within the specified boundaries. Returns a copy of the input data with rows outside the boundary removed.

Return type:

pd.DataFrame

Raises:

ValueError – If corners is not a dictionary or DataFrame

Examples

>>> import pandas as pd
>>> data = pd.DataFrame({'x': [0, 5, 10], 'y': [0, 5, 10], 'z': [1, 2, 3]})
>>> corners = {'x': [2, 8], 'y': [2, 8]}
>>> filtered = select_data(data, corners)
>>> print(filtered)
   x  y  z
1  5  5  2