next up previous 264
Next: ...Display Coordinates as they are Transformed
Up: How To...
Previous: ...Test if a WCS is a Spectral Coordinate System


...Format Coordinates for Display

Once you have converted pixel coordinates into world coordinates ([*]), you may want to format them as text before displaying them. Typically, this would convert from (say) radians into something more comprehensible. Using the FrameSet pointer ``wcsinfo'' obtained in [*] and a pair of world coordinates ``xw'' and ``yw'' (e.g. see [*]), you could proceed as follows:

#include <stdio.h>
const char *xtext, *ytext;
double xw, yw;

...

xtext = astFormat( wcsinfo, 1, xw );
ytext = astFormat( wcsinfo, 2, yw );

(void) printf( "Position = %s, %s\n", xtext, ytext );

Here, the second argument to astFormat is the axis number.

With celestial coordinates, this will usually result in sexagesimal notation, such as ``12:34:56.7''. However, the same method may be applied to any type of coordinates and appropriate formatting will be employed.

For more information about formatting coordinate values and how to control the style of formatting used, see [*] and [*]. If necessary, also see [*] for details of how to ``normalise'' a set of coordinates so that they lie within the standard range (e.g. 0 to 24 hours for right ascension and $\pm 90^\circ$ for declination).


next up previous 264
Next: ...Display Coordinates as they are Transformed
Up: How To...
Previous: ...Test if a WCS is a Spectral Coordinate System

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