-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Understanding and implementing coordinate generation to geoxarray #12
Comments
Hi @djhoese, thanks for following up about this! If the coordinate generation doesn't go into geoxarray, I think an appropriate place would be the new xarray backend for kerchunk (xref fsspec/kerchunk#372). That would be better than a standalone accessor like xrefcoord IMO because the coordinates generated from the GeoTiff metadata will only be correct if there's no slicing done first, which motivates generating them while opening the dataset. Let me know if you have thoughts about which is better.
Good question, it doesn't (e.g., #13).
Kerchunk puts the GeoTiff metadata into .zattrs, which is loaded by the Zarr backend into attrs. Kerchunk uses Tifffile to extract the GeoTiff metadata, which is done here: https://github.com/cgohlke/tifffile/blob/5ced58caa74936ecc53f58ade94938e251e83138/tifffile/tifffile.py#L9841-L9922 |
Just curious, is this tifffile loaded tiff -> DataArray in a separate library at all? Does tifffile have an xarray engine to load files with |
Oh and I see when I load a geotiff with tifffile it includes a |
I don't know of a tifffile xarray backend. I use
It would be in .zattrs in the reference file. Here's an example from https://projectpythia.org/kerchunk-cookbook/notebooks/generating_references/GeoTIFF.html:
Note this includes When the kerchunk backend used to create a xarray dataset, the metadata gets loaded into storage_options = {
"remote_protocol": "s3",
"skip_instance_cache": True,
} # options passed to fsspec
open_dataset_options = {"chunks": {}} # opens passed to xarray
ds = xr.open_dataset(
"references/202301012300.json",
engine="kerchunk",
storage_options=storage_options,
open_dataset_options=open_dataset_options,
)
ds.attrs {'multiscales': [{'datasets': [{'path': '0'},
{'path': '1'},
{'path': '2'},
{'path': '3'},
{'path': '4'},
{'path': '5'}],
'metadata': {},
'name': '',
'version': '0.1'}],
'GDAL_METADATA': '<GDALMetadata>\n<Item name="Observation time" format="YYYYMMDDhhmm">202301012300</Item>\n<Item name="Quantity" unit="mm">Precipitation accumulation</Item>\n<Item name="Gain">0.010000</Item>\n<Item name="Offset">0.000000</Item>\n<Item name="Nodata">65535</Item>\n<Item name="Undetect">0</Item>\n<Item name="Accumulation time" unit="h">24</Item>\n<Item name="Temporal type">Past</Item>\n<Item name="Z=AR^B relation parameter A">200.000000</Item>\n<Item name="Z=AR^B relation parameter B">1.600000</Item>\n</GDALMetadata>\n',
'KeyDirectoryVersion': 1,
'KeyRevision': 1,
'KeyRevisionMinor': 0,
'GTModelTypeGeoKey': 1,
'GTRasterTypeGeoKey': 1,
'GTCitationGeoKey': 'ETRS89 [/](https://file+.vscode-resource.vscode-cdn.net/) TM35FIN(E,N)',
'GeogCitationGeoKey': 'ETRS89',
'GeogAngularUnitsGeoKey': 9102,
'GeogTOWGS84GeoKey': [0.0, 0.0, 0.0],
'ProjectedCSTypeGeoKey': 3067,
'ProjLinearUnitsGeoKey': 9001,
'ModelPixelScale': [1169.2930568410832, 1168.8701637541064, 0.0],
'ModelTiepoint': [0.0, 0.0, 0.0, -118331.36640835612, 7907751.537263516, 0.0]} |
I was pointed here by @maxrjones a long time ago as part of the NASA ACCESS19 Pangeo project. The main point of the conversation (over email) was that the coordinate generation done by this project could be something that the geoxarray project could do. I'm looking at implementing this but I was hoping I could get some more information to guide me. I'm trying to keep interfaces similar, if not exactly the same, with rioxarray, but also trying to avoid the rasterio/GDAL dependencies.
Looking at the main coordinate function here:
xrefcoord/xrefcoord/coords.py
Lines 35 to 46 in f7c46c8
imagecodecs
have to be loaded here?attrs
? GDAL's python interfaces don't use the geotiff ModelPixelScale/ModelTiepoint names but refer to numbers like these as the geotransform. While I would definitely have support for the geotransform in geoxarray I'd be fine having support for the ModelPixelScale naming too, I'd just like to know what to reference if there is a standard tool generating this.I might have more questions later, but any info toward the above would be a big help.
The text was updated successfully, but these errors were encountered: