Closed boothmanrylan closed 10 months ago
Writing to geotiff and then uploading to earth engine produces an image that is located in the wrong location
Hello @boothmanrylan you haven't passed EPSG:4326
into the to_raster
.
ds = xr.open_dataset(
col,
engine="ee",
scale=10,
crs="epsg:32610",
geometry=geometry,
)
to_raster(ds.mean(dim="time"), "dataset.tif")
Due to this, the raster created is in projection EPSG:32610
. Furthermore raster created for unprojected_ds
is in EPSG:4326
. In reality images are plotted in the correct location as per its projection (plotting depends on image projection).
So If you pass EPSG:4326
into the to_raster
for the above code then it will match with unprojected_ds
raster file.
And we do agree that dataset's coordinates not comes into given crs
(like for 'EPSG:32610' it should be in 'm') instead it's coming into degree
always.
This seems to lead to errors later on when attempting to write results back to a geotiff using rioxarray.
Full notebook to reproduce: https://colab.research.google.com/drive/149vNtVZ0lGJn5PXxfn7oaTS1VoJX0Qec?usp=sharing
Opening a dataset without specifying a crs:
And then writing to a geotiff using:
And then uploading that geotiff to earth engine produces an image that has the right dimensions and is located properly:
Opening a dataset with a specific crs:
Writing to geotiff and then uploading to earth engine produces an image that is located in the wrong location (over the equator in the pacific ocean, should be over san francisco), has the wrong dimensions (225x181 vs 203x206), and the wrong scale (0.000103m vs 10m):
Transforming the coordinates of a dataset opened with a crs:
And then uploading to earth engine, produces an image that is properly located and has the right dimensions (the scale is slightly off, but I think that has to do with the hacky method I'm using to transform the coordinates here):