environmentaltools.spatial.global_to_local_coords
- environmentaltools.spatial.global_to_local_coords(x_glob, y_glob, alpha, lon_0_glob, lat_0_glob)[source]
Transform global coordinates to local rotated coordinate system.
Converts coordinates from a global reference system to a local coordinate system defined by an origin point and rotation angle. Useful for analyzing data in a local shore-normal/shore-parallel reference frame.
- Parameters:
x_glob (float or np.ndarray) – Global X coordinates (e.g., UTM easting or longitude)
y_glob (float or np.ndarray) – Global Y coordinates (e.g., UTM northing or latitude)
alpha (float) – Rotation angle in degrees defining local coordinate system orientation
lon_0_glob (float) – Global X coordinate of local system origin
lat_0_glob (float) – Global Y coordinate of local system origin
- Returns:
x_loc (float or np.ndarray) – Local X coordinates (along rotated axis)
y_loc (float or np.ndarray) – Local Y coordinates (perpendicular to rotated axis)
Notes
The transformation applies: 1. Translation to move origin to (lon_0_glob, lat_0_glob) 2. Rotation by angle alpha
Examples
>>> x_glob, y_glob = 100.0, 200.0 >>> x_loc, y_loc = global_to_local_coords(x_glob, y_glob, 45, 0, 0)