Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

'reference' option not implemented in Python API #50

Open
ahamaline opened this issue Sep 26, 2021 · 1 comment
Open

'reference' option not implemented in Python API #50

ahamaline opened this issue Sep 26, 2021 · 1 comment

Comments

@ahamaline
Copy link

According to the documentation, "Every command has a corresponding API function in the elevation module". However, the option to use a 'reference' image rather than the explicit 'bounds' only works in the CLI and not in the Python API.

This is not a serious problem because one can easily find the bounds using rasterio, which must be installed anyway. But this information needs to be explained in the documentation.

@ahamaline
Copy link
Author

ahamaline commented Sep 26, 2021

To be explicit, assume 'reference' is the address string for your reference file, as in the CLI. Then you can use:

import rasterio
ds = rasterio.open(reference)
elevation.clip(bounds = ds.bounds, ... )

Another point to note is that both this and the CLI option only work if you reference GeoTIFF has a 'GeoTransform' saved. Many files such as satellite images do not use this; instead they record the location using Ground Control Points. In this case getting the bounds requires a bit more work. The function to use is rasterio.transform.from_gcps, which should generate a geotransform, which can then be applied to find the bounds. But I don't know how to do this in detail.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant