Skip to content
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

Add utility function for converting geotiffs to area definitions #92

Closed
djhoese opened this issue Jan 8, 2018 · 9 comments
Closed

Add utility function for converting geotiffs to area definitions #92

djhoese opened this issue Jan 8, 2018 · 9 comments

Comments

@djhoese
Copy link
Member

djhoese commented Jan 8, 2018

Users some time want to get an area definition for a geotiff file. This isn't a difficult thing to do necessarily, but is easy to get wrong. @loerum has already added this type of functionality to mipp for reading SARS data, but it could likely be rewritten or made more flexible: https://github.com/pytroll/mipp/blob/master/mipp/read_geotiff.py

I think if the function just takes a gdal object gdal.Open(fn) and uses the GDAL API for getting the projection information it may work for more than just geotiff.

@djhoese djhoese added the good first issue Easy-to-fix issue label Feb 28, 2018
@mraspaud mraspaud assigned mraspaud and unassigned mraspaud Apr 26, 2018
@drnextgis
Copy link
Contributor

Hi @djhoese I'm on it.

@pnuu
Copy link
Member

pnuu commented Oct 8, 2018

We already have it, although it needs also the CRS object from rasterio: https://github.com/pytroll/satpy/blob/master/satpy/readers/generic_image.py#L103

@djhoese
Copy link
Member Author

djhoese commented Oct 8, 2018

@drnextgis Sounds good. I think you could borrow the logic that @pnuu links to, but I'd still like this type of utility in pyresample itself. Some of the logic for this will overlap with what is being done in #138 but that's ok since that PR isn't ready quite yet.

I'm assuming you are trying to get hacktoberfest PRs?

I think the utility function should accept either a filename, a gdal object, or a rasterio object. If a filename is specified then import rasterio and open it. Then it will do whatever calculations are necessary to generate an AreaDefinition.

@drnextgis
Copy link
Contributor

Yes I found this issue by hackctoberfest tag. But it is a good opportunity to know more about pyresample.

@drnextgis
Copy link
Contributor

drnextgis commented Oct 16, 2018

I start to work on this issue. In example provided by @pnuu the rotation of source raster is not taken into account. But I have questions about this. For example rasterio's bounds method takes into account rotation rasterio/rasterio#1420 (fixed). Is it expected by AreaDefinition constructor that area_extent parameter calculated with taking into account a rotation? I see at least two possible option, but maybe I miss something:

  • pass to area_extent bbox calculated by rasterio + affine rotation to rotation argument
  • pass to area_extent and rotation values of affine of source image

What is the right approach?

@djhoese
Copy link
Member Author

djhoese commented Oct 16, 2018

@drnextgis Do you have an example?

@drnextgis
Copy link
Contributor

Example of rotated raster?

@djhoese
Copy link
Member Author

djhoese commented Oct 16, 2018

Sorry, I misunderstood your question. The rotation argument should be the degrees of rotation:

    rotation: float
        rotation in degrees (negative is cw)

So I guess you could calculate that from the affine rotation. I don't use a lot of rotated area definitions so I can speak on the best way to do this. @mraspaud or @pnuu or @loreclem may have other opinions.

@drnextgis drnextgis mentioned this issue Oct 21, 2018
5 tasks
@drnextgis
Copy link
Contributor

I've made a PR, please take a look.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants