Project geographical coordinates. Parameters ---------- coordinates : array_like NumPy ndarray of size (N, 2) describing longitude, latitude. proj_string : str Definition of output projection. Returns ------- array_like NumPy ndarray with shape (
(coordinates, proj_string, in_radians=False)
| 114 | |
| 115 | |
| 116 | def project(coordinates, proj_string, in_radians=False): |
| 117 | """Project geographical coordinates. |
| 118 | |
| 119 | Parameters |
| 120 | ---------- |
| 121 | coordinates : array_like |
| 122 | NumPy ndarray of size (N, 2) describing longitude, latitude. |
| 123 | proj_string : str |
| 124 | Definition of output projection. |
| 125 | |
| 126 | Returns |
| 127 | ------- |
| 128 | array_like |
| 129 | NumPy ndarray with shape (N, 2) with N pairs of 2D |
| 130 | coordinates (x, y). |
| 131 | """ |
| 132 | # proj expects binary input to be in radians |
| 133 | if not in_radians: |
| 134 | coordinates = np.deg2rad(coordinates, order="C", dtype=np.float64) |
| 135 | else: |
| 136 | coordinates = coordinates.astype(np.float64, order="C", copy=False) |
| 137 | |
| 138 | # set up cmd call. -b for binary in/out |
| 139 | args = ["-b"] + proj_string.split(" ") |
| 140 | proc = run_proj_cmd(args, input=coordinates.tobytes(order="C")) |
| 141 | |
| 142 | out = np.frombuffer(proc.stdout, dtype=np.float64) |
| 143 | return np.reshape(out, (-1, 2)) |
| 144 | |
| 145 | |
| 146 | def project_geoms(geoms, proj_string): |
no test coverage detected