You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Transforms a coordinate from a source projection to a target projection using pyproj.
323
330
331
+
Args:
332
+
coordinate (list): A list representing the coordinate to be transformed, in the format [x, y].
333
+
src_proj (str or dict): The source projection, either as a string (e.g. "EPSG:4326") or a dictionary with a "definition" key containing the projection string.
334
+
target_proj (str or dict): The target projection, either as a string (e.g. "EPSG:3857") or a dictionary with a "definition" key containing the projection string.
335
+
Returns:
336
+
A list representing the transformed coordinate in the target projection, in the format [x, y].
337
+
Raises:
338
+
ValueError: If src_proj or target_proj are not in the expected formats.
339
+
tethys_portal.optional_dependencies.MissingOptionalDependency: If the pyproj library is not installed.
340
+
"""
324
341
ifisinstance(src_proj, dict):
325
-
source_crs=CRS(src_proj["definition"])
342
+
source_crs=pyproj.CRS(src_proj["definition"])
326
343
elifisinstance(src_proj, str):
327
-
source_crs=CRS(src_proj)
344
+
source_crs=pyproj.CRS(src_proj)
328
345
else:
329
346
raiseValueError(
330
347
"src_proj must be a string or dictionary with a definition key"
331
348
)
332
349
333
350
ifisinstance(target_proj, dict):
334
-
target_crs=CRS(target_proj["definition"])
351
+
target_crs=pyproj.CRS(target_proj["definition"])
335
352
elifisinstance(target_proj, str):
336
-
target_crs=CRS(target_proj)
353
+
target_crs=pyproj.CRS(target_proj)
337
354
else:
338
355
raiseValueError(
339
356
"target_proj must be a string or dictionary with a definition key"
They are converted back to ReactPy propery dictionaries when accessed.
350
367
351
368
Example:
352
-
Instead of lib.html.div({"backgroundColor": "red", "fontSize": "12px"}, "Hello"), you can use lib.html.div(Props(background_color="red, font_size="12px"), "Hello")
369
+
Instead of lib.html.div({"backgroundColor": "red", "fontSize": "12px"}, "Hello"), you can use lib.html.div(Props(background_color="red", font_size="12px"), "Hello")
0 commit comments