cartopy
cartopy copied to clipboard
Miller projection issues
I'm running v 0.18.0.
Since I'm new to cartopy, not sure if other projections also suffer from these kind of problems. I'm plotting on Miller projection. I found that the x, y values you give do not corresponds to the actual longitude / latitude on the plot.
- central_longitude value other than 0 shows map with appropriate , but the longitudes are not matched. For instance, plotting (0, 45) should show a point in Europe, but with central_longitude=170, it's in the middle of pacific.
1.1. Related to this: Might not be restricted to Miller projection itself, but I found it difficult to make map longitude extent to be more than 360 degrees. I've recently moved from basemap
where they supported this feature, but here it seems that if the central longitude is 0, you can only draw from -180 to 180. For instance what I want to draw is between -20 to 350, which is more than a full turn. I am not sure if this is me not finding the correct way, but if this is not a feature supported yet, you should support this.
- I expected, under
transform=crs
keyword, what you put as y value (e.g., in theset_extent()
or in plotted points) should be latitude. This is not the case in Miller projection, and the latitude is limited by 131.98, which is very odd number.
In the Miller projection source code, the comment
# XXX How can we derive the vertical limit of 131.98?
super(Miller, self).__init__(proj4_params, 180, 131.98, globe=globe)
suggests that it uses transformed coordicate to produce Mercator-equivalent projection. I found that
def proj_to_lat(proj):
return 1.25*np.arctan(np.sinh(proj*(np.pi/225)))*(180/np.pi) # np.sinh(4*proj*(np.pi/180)/5)
def lat_to_proj(lat):
return 1.25*np.arcsinh(np.tan(lat*(np.pi/225)))*(180/np.pi)
can be used to transform the numbers correctly, but the y value should really be just latitude instead of this transformed value. For instance, to plot on the north pole,
plot(90,90, marker='o')
is incorrect, but plot(90,lat_to_proj(90), marker='o')
is correct. (adding transform=crs
changes nothing) It really should just be able to plot anything with latitude numbers.
Please post exactly what code it is you are using that doesn't seem to be working.
I'm not sure what code you are looking at, but this is the explanation with references for the Miller projection. https://github.com/SciTools/cartopy/blob/ecabeb883afb4d450f369afe4819ea743b8c73dc/lib/cartopy/crs.py#L1901-L1904 You should upgrade to v0.20 if you want the latest updates, as we did significant work in being more compatible with PROJ and some coordinate values may be changed.
Coordinates you get back from plots are not going to be (lon, lat), they are going to be projection coordinates (x, y). These values and limits are different for every projection.