Open astrofrog opened 8 years ago
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
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 theData
instance in the data factory inglue_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).