AlDanial
AlDanial

Reputation: 449

longitude off by 180 degrees with cartopy Orthographic and RotatedPole

I'm trying to place blue dots from the North pole down the prime meridian (longitude=0) but instead see the dots going down the dateline (longitude=180). The code:

#!/usr/bin/env python
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
Lon = 0
ax = plt.axes( projection=ccrs.Orthographic( central_latitude=70,
                                             central_longitude=Lon) )
ax.set_global()
vector_crs = ccrs.RotatedPole( pole_latitude=90, pole_longitude=Lon )
ax.plot([Lon, Lon, Lon, Lon, Lon, Lon],   # longitude
        [ 90,  80,  70,  60,  50,  40],   # latitude
        'bo', markersize=5, transform=vector_crs)
ax.stock_img()
plt.show()

enter image description here

Probably something related to the transforms but I haven't figured out what. Cartopy version 0.14.2, Python 3.6.

Upvotes: 0

Views: 1796

Answers (1)

DPeterK
DPeterK

Reputation: 408

I think the problem is coming from the transform projection that you've defined:

ax = plt.axes(projection=vector_crs)
ax.coastlines()
plt.show()

transform used as plot projection

Note that this simple coastlines plot in your transform projection looks like a Plate Carree plot with a central longitude of 180°. With this in mind, let's take a look at plotting your sample data points on a plot with a Plate Carree projection in order to also try simplifying the map you're plotting to:

ax = plt.axes(projection=ccrs.PlateCarree()) 
ax.plot([Lon, Lon, Lon, Lon, Lon, Lon],
        [ 90,  80,  70,  60,  50,  40],
        'bo', markersize=5, transform=vector_crs)
ax.stock_img()
plt.show()

transform onto PlateCarree projection

As with your example, the points do not appear where we might expect. Finally, let's try using a Plate Carree projection as the transform for your points when plotting them onto an Orthographic map:

ax = plt.axes(projection=ccrs.Orthographic(central_latitude=70,
                                           central_longitude=Lon))
ax.set_global()
ax.plot([Lon, Lon, Lon, Lon, Lon, Lon],
        [ 90,  80,  70,  60,  50,  40],
        'bo', markersize=5, transform=ccrs.PlateCarree())
ax.stock_img()
plt.show()

PlateCarree transform onto Orthographic plot

This seems to provide more the plot you were looking for.

Upvotes: 2

Related Questions