Skip to content

transform: transform coordinate between projection

Commands of moraine.cli.transform (source); the same functions are called in Python as mc.<name>(...) with import moraine.cli as mc. The help below is generated from the docstrings, like moraine COMMAND --help.

command summary
transform Coordinate transformation

transform

Coordinate transformation. By default, the input should be longitude (xx_in) and latitude (yy_in) (in degree) and outputs are x (east) and y (south) coordinate in web mercator projection (for plot with google earth map). The chunks, shape and dtype of output are same as xx_in.

moraine transform --xx_in VALUE --yy_in VALUE --xx_out VALUE --yy_out VALUE [--epsg_in VALUE] [--epsg_out VALUE]
argument type default description
--xx_in required input x coordinate (longitude in degree for the default epsg_in)
--yy_in required input y coordinate (latitude in degree for the default epsg_in)
--xx_out required output x coordinate in epsg_out, same shape and chunks as xx_in
--yy_out required output y coordinate in epsg_out, same shape and chunks as xx_in
--epsg_in int 4326 EPSG code of the input coordinates (4326: WGS84 longitude/latitude)
--epsg_out int 3857 EPSG code of the output coordinates (3857: web mercator)

Global options: --json, --traceback, --log FILE, -q / --quiet (conventions).

In a pipeline (examples/01_load.toml, step web_mercator):

[[step]]
name = "web_mercator"             # e/n coordinates, used to plot point clouds on a map
run = "transform"
xx_in = "raw/lon.zarr"
yy_in = "raw/lat.zarr"
xx_out = "raw/e.zarr"
yy_out = "raw/n.zarr"

In Python:

import moraine.cli as mc
mc.transform(xx_in, yy_in, xx_out, yy_out, epsg_in=4326, epsg_out=3857)