-
I'm hoping someone here might be monitoring this and help me to create a list of geographic points (lon/lat) from the UTM zone and a lower-left corner. That is I have gridded matrix (shape is (2527, 2695)) of bathymetry depths that I want to plot in geographic context. The metadata that I have is the UTM zone, cell size, units (meters), a lower-left corner in meters (340700,2468000) spheroid, datum, shifting value and some other information that I don't think is of consequence to my goal plotting this information. If I can get the lon/lat associated with each grid point then I can plot it using various methods that I know, I just want to accurately place the information on the globe, which does not appear trivial from my vantage point. Thanks in advance for any insights/help. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
What is the cell size? Step 1: Build the transformBased on what you have, you can construct the affine/transform: https://github.com/sgillies/affine This is helpful for determining the order: https://gdal.org/user/raster_data_model.html#affine-geotransform from affine import Affine
resolution_x = 100 # right
resolution_y = -100 # down
left = 340700
bottom = 2468000
top = bottom - resolution_y * height
transform = Affine.translation(left, top) * Affine.scale(resolution_x, resolution_y) Step 2: Get the CRS from UTM Zonehttps://pyproj4.github.io/pyproj/stable/build_crs.html#projected-crs from pyproj.crs import ProjectedCRS
from pyproj.crs.coordinate_operation import UTMConversion
crs = ProjectedCRS(conversion=UTMConversion(14)) Step 3: Assign the transform/affine & CRS to raster
import rioxarray
import xarray
rds = xarray.DataArray(data, dims=("y", "x"))
rds.rio.write_transform(transform, inplace=True)
rds.rio.write_crs(crs, inplace=True) Step 4: Re-project to geographicrds = rds.rio.reproject("EPSG:4326") |
Beta Was this translation helpful? Give feedback.
What is the cell size?
Step 1: Build the transform
Based on what you have, you can construct the affine/transform: https://github.com/sgillies/affine
This is helpful for determining the order: https://gdal.org/user/raster_data_model.html#affine-geotransform
Step 2: Get the CRS from UTM Zone
https://pyproj4.github.io/pyproj/stable/build_crs.html#projected-crs