Commit bb609e4c authored by Cecilia Nievas's avatar Cecilia Nievas
Browse files

Added function retrieve_coords_to_adjust

parent 7197934f
......@@ -846,3 +846,54 @@ def determine_cardinal_point(in_theta, theta_thr, inputangle="radians"):
] = "SE"
return out_card
def retrieve_coords_to_adjust(cardinal_str):
"""This function returns the position of the coordinates that need to be changed in two
cells/tiles whose relative position is given by cardinal_str so that there is no overlap
or gap between them. The position refers to the west (0), south (1), east (2), north (3)
coordinates of shapely.polygon.bounds.
Args:
cardinal_str (str): N, S, E, W, NE, NW, SE, SW
Returns:
which_to_adj_1 (list): Position of the coordinate to be changed in the first cell
when the second cell is located to its cardinal_str. The
position refers to the west (0), south (1), east (2), north (3)
coordinates of shapely.polygon.bounds.
which_to_adj_2 (list): Position of the coordinate to be changed in the second cell
when it is located to the cardinal_str of the first cell.
The position refers to the west (0), south (1), east (2), north
(3) coordinates of shapely.polygon.bounds.
"""
if cardinal_str == "E":
which_to_adj_1 = [2] # East
which_to_adj_2 = [0] # West
elif cardinal_str == "NE":
which_to_adj_1 = [2, 3] # East & north
which_to_adj_2 = [0, 1] # West & south
elif cardinal_str == "N":
which_to_adj_1 = [3] # North
which_to_adj_2 = [1] # South
elif cardinal_str == "NW":
which_to_adj_1 = [3, 0] # North & west
which_to_adj_2 = [1, 2] # South & east
elif cardinal_str == "W":
which_to_adj_1 = [0] # West
which_to_adj_2 = [2] # East
elif cardinal_str == "SW":
which_to_adj_1 = [1, 0] # South & west
which_to_adj_2 = [3, 2] # North & east
elif cardinal_str == "S":
which_to_adj_1 = [1] # South
which_to_adj_2 = [3] # North
elif cardinal_str == "SE":
which_to_adj_1 = [1, 2] # South & east
which_to_adj_2 = [3, 0] # North & west
else:
which_to_adj_1 = [9] # error
which_to_adj_2 = [9] # error
return which_to_adj_1, which_to_adj_2
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment