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

Correctly read in coordinate system information #2

Open
astrofrog opened this issue May 19, 2016 · 1 comment
Open

Correctly read in coordinate system information #2

astrofrog opened this issue May 19, 2016 · 1 comment

Comments

@astrofrog
Copy link
Member

astrofrog commented May 19, 2016

This would allow for example linking of different images by spatial coordinates.

Once we figure out how to get a transformation function, we should create a subclass of glue.core.coordinates.Coordinates that wraps this transformation, and we should attach the coordinates object to the Data instance in the data factory in glue_geospatial/data_factory.py.

To get the coordinates to be shown properly on plots, we will need to make it so that WCSAxes doesn't take a WCS object but a transformation function (or pair of functions).

@robintw
Copy link
Collaborator

robintw commented May 25, 2016

I'm going to try and have a go at this sometime soon. Just making a few notes here for my benefit:

Example of Co-ords class in glue: https://github.com/glue-viz/glue/blob/master/glue/core/coordinates.py

In rasterio, two attributes give basically the same data:

In [7]: src.transform
/opt/anaconda3/lib/python3.4/site-packages/IPython/core/interactiveshell.py:3066: FutureWarning: The value of this property will change in version 1.0. Please see https://github.com/mapbox/rasterio/issues/86 for details.
  exec(code_obj, self.user_global_ns, self.user_ns)
Out[7]: [430130.2396, 10.0, 0.0, 148415.8755, 0.0, -10.0]

In [8]: src.affine
Out[8]: 
Affine(10.0, 0.0, 430130.2396,
       0.0, -10.0, 148415.8755)

See https://mapbox.s3.amazonaws.com/playground/perrygeo/rasterio-docs/api_docs.html#rasterio.open

An affine transformation that maps col,row pixel coordinates to x,y coordinates in the coordinate reference system can be specified using the transform argument. The value should be an instance of affine.Affine

>>> from affine import Affine
>>> Affine(0.5, 0.0, -180.0, 0.0, -0.5, 90.0)
These coefficients are shown in the figure below.

| x |   | a  b  c | | c |
| y | = | d  e  f | | r |
| 1 |   | 0  0  1 | | 1 |

  a: rate of change of X with respect to increasing column, i.e.  pixel width
  b: rotation, 0 if the raster is oriented "north up"
  c: X coordinate of the top left corner of the top left pixel
  d: rotation, 0 if the raster is oriented "north up"
  e: rate of change of Y with respect to increasing row, usually
          a negative number (i.e. -1 * pixel height) if north-up.
  f: Y coordinate of the top left corner of the top left pixel

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

No branches or pull requests

2 participants