import numpy as np
from matplotlib import pyplot as plt
import moraine.cli as mc
transform
transform coordinate between projection
transform
transform (xx_in, yy_in, xx_out, yy_out, epsg_in=4326, epsg_out=3857)
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
.
Type | Default | Details | |
---|---|---|---|
xx_in | input x coordinate | ||
yy_in | input y coordinate | ||
xx_out | output x coordinate | ||
yy_out | output y coordinate | ||
epsg_in | int | 4326 | input epsg |
epsg_out | int | 3857 | output epsg |
transform
do not have the API version since it can be easily achieved with pyproj
.
Usage:
= './raw/lon.zarr/'; lat_ = './raw/lat.zarr/'
lon_ = './transform/e.zarr'; n_ = './transform/n.zarr' e_
= mc.get_logger() logger
transform(lon_,lat_,e_,n_)
2024-06-07 15:53:56 - log_args - INFO - running function: transform
2024-06-07 15:53:56 - log_args - INFO - fetching args:
2024-06-07 15:53:56 - log_args - INFO - xx_in = './raw/lon.zarr/'
2024-06-07 15:53:56 - log_args - INFO - yy_in = './raw/lat.zarr/'
2024-06-07 15:53:56 - log_args - INFO - xx_out = './transform/e.zarr'
2024-06-07 15:53:56 - log_args - INFO - yy_out = './transform/n.zarr'
2024-06-07 15:53:56 - log_args - INFO - epsg_in = 4326
2024-06-07 15:53:56 - log_args - INFO - epsg_out = 3857
2024-06-07 15:53:56 - log_args - INFO - fetching args done.
2024-06-07 15:53:56 - transform - INFO - input EPSG: 4326.
2024-06-07 15:53:56 - zarr_info - INFO - xx_in zarray shape, chunks, dtype: (2500, 1834), (1000, 1000), float64
2024-06-07 15:53:56 - zarr_info - INFO - yy_in zarray shape, chunks, dtype: (2500, 1834), (1000, 1000), float64
2024-06-07 15:53:56 - transform - INFO - output EPSG: 3857.
2024-06-07 15:53:56 - transform - INFO - do the transformation.
2024-06-07 15:53:59 - transform - INFO - write output.
2024-06-07 15:53:59 - transform - INFO - write done.
= zarr.open(lon_,mode='r')[:]
lon = zarr.open(lat_,mode='r')[:] lat
= plt.subplots(1,2,figsize=(11,5))
fig,axes = axes[0].imshow(lon)
im0 0].set_title('Longitude')
axes[=axes[0])
fig.colorbar(im0, ax= axes[1].imshow(lat)
im1 1].set_title('Latitude')
axes[=axes[1])
fig.colorbar(im1, ax fig.show()
= zarr.open(e_,mode='r')[:]
e = zarr.open(n_,mode='r')[:] n
= plt.subplots(1,2,figsize=(11,5))
fig,axes = axes[0].imshow(e)
im0 0].set_title('E')
axes[=axes[0])
fig.colorbar(im0, ax= axes[1].imshow(n)
im1 1].set_title('N')
axes[=axes[1])
fig.colorbar(im1, ax fig.show()