How to use the provided "PROJ4 string" while using "Cartopy" in python?

232 Views Asked by At

I have sea ice concentration values, x and y in meters (3 vectors with the same dimension) and I have the PROJ4 string: "Northern Hemisphere: +proj=stere +lat_0=90 +lat_ts=70 +lon_0=-45 +k=1 +x_0=0 +y_0=0 +a=6378273 +b=6356889.449 +units=m +no_defs".

How to plot it in Python (with having x and y in meters)? How do I know which projection and CRS I should use? I wrote this code, but it does not work properly:

ax = fig.add_subplot(1,1,1, projection=crs.NorthPolarStereo(central_longitude=0))
ax.add_feature(cfeature.COASTLINE)
ax.add_feature(cfeature.LAND, color="black", alpha=0.5)
ax.add_feature(cfeature.OCEAN, color="white", alpha=0.3)
kw = dict(central_latitude=0, central_longitude=0)
sc = plt.scatter(x_coords, y_coords, c=values, cmap='jet', s=10,
            transform=crs.Stereographic(**kw))
cbar = plt.colorbar()
ax.gridlines(crs=crs.PlateCarree(), draw_labels=True,
                  linewidth=0.1, color='gray', alpha=0.5, linestyle='--')
plt.show()
1

There are 1 best solutions below

5
swatchai On
Q: which projection and CRS I should use?
A: NorthPolarStereo() with proper options, try this
use_proj = NorthPolarStereo(central_longitude=-45, true_scale_latitude=70)
Other possible causes of errors:

When you plot the data units= lat/long degrees, 
you must set "transform" option correctly. 

For example, in the statement "plt.scatter(...)" you must set
the option transform as following:-
transform = crs.PlateCarree()
If the data (x,y) are in the coordinates of NorthPolarStereo(...) defined above, 
the proper option is
transform = use_proj