MCPcopy Create free account
hub / github.com/OSGeo/PROJ / project

Function project

docs/plot/plot.py:116–143  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

114
115
116def 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
146def project_geoms(geoms, proj_string):

Callers 1

project_geomsFunction · 0.85

Calls 1

run_proj_cmdFunction · 0.85

Tested by

no test coverage detected