'Transform this coordinate to a new frame.
The precise frame transformed to depends on ``merge_attributes``.
If `False`, the destination frame is used exactly as passed in.
But this is often not quite what one wants.  E.g., suppose one wants to
transform an ICRS coordinate that has an obstime attribute to FK4; in
this case, one likely would want to use this information. Thus, the
default for ``merge_attributes`` is `True`, in which the precedence is
as follows: (1) explicitly set (i.e., non-default) values in the
destination frame; (2) explicitly set values in the source; (3) default
value in the destination frame.
Note that in either case, any explicitly set attributes on the source
`SkyCoord` that are not part of the destination frame\'s definition are
kept (stored on the resulting `SkyCoord`), and thus one can round-trip
(e.g., from FK4 to ICRS to FK4 without loosing obstime).
Parameters
frame : str, `BaseCoordinateFrame` class or instance, or `SkyCoord` instance
The frame to transform this coordinate into.  If a `SkyCoord`, the
underlying frame is extracted, and all other information ignored.
merge_attributes : bool, optional
Whether the default attributes in the destination frame are allowed
to be overridden by explicitly set attributes in the source
(see note above; default: `True`).
Returns
coord : `SkyCoord`
A new object with this coordinate represented in the `frame` frame.
Raises
ValueError
If there is no possible transformation route.'

def transform_to(self, frame, merge_attributes=True):

    from astropy.coordinates.errors import ConvertError
    frame_kwargs = {}
    try:
        frame = _get_frame_class(frame)()
    except Exception:
        pass
    if isinstance(frame, SkyCoord):
        frame = frame.frame
    if isinstance(frame, BaseCoordinateFrame):
        new_frame_cls = frame.__class__
        for attr in frame_transform_graph.frame_attributes:
            self_val = getattr(self, attr, None)
            frame_val = getattr(frame, attr, None)
            if ((frame_val is not None) and (not (merge_attributes and frame.is_frame_attr_default(attr)))):
                frame_kwargs[attr] = frame_val
            elif ((self_val is not None) and (not self.is_frame_attr_default(attr))):
                frame_kwargs[attr] = self_val
            elif (frame_val is not None):
                frame_kwargs[attr] = frame_val
    else:
        raise ValueError(u'Transform    `frame`    must    be    a    frame    name,    class,    or    instance')
    trans = frame_transform_graph.get_transform(self.frame.__class__, new_frame_cls)
    if (trans is None):
        raise ConvertError(u'Cannot    transform    from    {0}    to    {1}'.format(self.frame.__class__, new_frame_cls))
    generic_frame = GenericFrame(frame_kwargs)
    new_coord = trans(self.frame, generic_frame)
    for attr in (set(new_coord.get_frame_attr_names()) & set(frame_kwargs.keys())):
        frame_kwargs.pop(attr)
    return self.__class__(new_coord, **frame_kwargs)
