next up previous 264
Next: ...Test if a WCS is a Celestial Coordinate System
Up: How To...
Previous: ...Display AST Data


...Convert Between Pixel and World Coordinates

You may use a pointer to a FrameSet, such as we read in [*], to transform a set of points between the pixel coordinates of an image and the associated world coordinates. If you are working in two dimensions, proceed as follows:

double xpixel[ N ], ypixel[ N ];
double xworld[ N ], yworld[ N ];

...

astTran2( wcsinfo, N, xpixel, ypixel, 1, xworld, yworld );

Here, N is the number of points to be transformed, ``xpixel'' and ``ypixel'' hold the pixel coordinates, and ``xworld'' and ``yworld'' receive the returned world coordinates.5 To transform in the opposite direction, interchange the two pairs of arrays (so that the world coordinates are given as input) and change the fifth argument of astTran2 to zero.

To transform points in one dimension, use astTran1. In any other number of dimensions (or if the number of dimensions is initially unknown), use astTranN or astTranP. These functions are described in [*].

For more information about transforming coordinates, see [*] and [*]. For details of how to handle missing coordinates, see [*].


next up previous 264
Next: ...Test if a WCS is a Celestial Coordinate System
Up: How To...
Previous: ...Display AST Data

AST A Library for Handling World Coordinate Systems in Astronomy
Starlink User Note 211
R.F. Warren-Smith & D.S. Berry
7th December 2012
E-mail:starlink@jiscmail.ac.uk

Copyright (C) 2012 Science \& Technology Facilities Council