I've got a python script that is comparing extents of rasters in various projections. Generally it works, but sometimes, especially when the rasters are global in extent or cross the dateline it fails. In effect I need an algorithm that will return if a longitude is 'more east' of another one. A simple greater than breaks down is some cases.
lon1 = 175 lon2 = 177 lon3 = -181 lon1 > lon2 #returns True lon2 is 'more east' than lon1 lon1 > lon3 #falsely returns False even though lon3 is more east than lon 1
And I don't think I can do a simple transform of my longitude to 0-360 as I don't have control over the incoming coordinate system. For example, in one custom Mollweide projection I'm working on 'x' is in meters and range from -18040094 to 18043982