Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equatorial Lambert equal-area azimuthal projection? #2495

Closed
ricitron opened this issue Jan 24, 2025 · 4 comments
Closed

Equatorial Lambert equal-area azimuthal projection? #2495

ricitron opened this issue Jan 24, 2025 · 4 comments

Comments

@ricitron
Copy link

Is there a way to do the equatorial Lambert equal-area azimuthal projection?

It should be like the Lambert equal-area azimuthal projection but with the option to set something like 'extent' to 90 degrees so it only plots one hemisphere, like the image below. Unfortunately I don't see how to do this with cartopy's projections.

Image

@edsaac
Copy link

edsaac commented Jan 29, 2025

Would ax.set_extent be what you are looking for?

Image

fig = plt.Figure(figsize=(6, 4))

# West Hemisphere
map_extent_west = (-180, 0, -90, 90)
map_proj_west = ccrs.LambertAzimuthalEqualArea(
    central_longitude=-90.0,
    central_latitude=0.0,
)

ax = fig.add_axes((0, 0, 0.45, 0.95), projection=map_proj_west)
ax.set_extent(map_extent_west, crs=ccrs.PlateCarree())

# East Hemisphere
map_extent_east = (0, 180, -90, 90)
map_proj_east = ccrs.LambertAzimuthalEqualArea(
    central_longitude=90.0,
    central_latitude=0.0,
)

ax = fig.add_axes((0.5, 0, 0.45, 0.95), projection=map_proj_east)
ax.set_extent(map_extent_east, crs=ccrs.PlateCarree())

for ax in fig.get_axes():
    ax.stock_img()
    ax.add_feature(cf.COASTLINE)
    ax.gridlines()

fig.savefig("hemispheres.png", bbox_inches="tight")

@ricitron
Copy link
Author

ricitron commented Jan 30, 2025

That isn't what I am looking for. I'm looking for the map to cut off at the defined horizon, so it is plotting just one hemisphere or the other, and it should be a circular image for each hemisphere, as in the example I provided.

It is seen in Generic Mapping Tools here:

https://docs.generic-mapping-tools.org/6.0/cookbook/map_projections.html#hemisphere-map

Image

@edsaac
Copy link

edsaac commented Jan 30, 2025

How about calling ax.set_boundary to clip the map?

Image

fig = plt.Figure(figsize=(6, 4))

# West Hemisphere
map_proj_west = ccrs.LambertAzimuthalEqualArea(
    central_longitude=-90.0,
    central_latitude=0.0,
)

ax = fig.add_axes((0, 0, 0.45, 1), projection=map_proj_west)
ax.set_extent((-180, 0, -90, 90), crs=ccrs.PlateCarree())
boundary = mpath.Path([(-180, -90), (-180, 90), (0, 90), (0, -90)])
ax.set_boundary(boundary, transform=ccrs.PlateCarree())

# East Hemisphere
map_proj_east = ccrs.LambertAzimuthalEqualArea(
    central_longitude=90.0,
    central_latitude=0.0,
)

ax = fig.add_axes((0.5, 0, 0.45, 1), projection=map_proj_east)
ax.set_extent((0, 180, -90, 90), crs=ccrs.PlateCarree())
boundary = mpath.Path([(0, -90), (0, 90), (180, 90), (180, -90)])
ax.set_boundary(boundary, transform=ccrs.PlateCarree())

for ax in fig.get_axes():
    ax.add_feature(cf.COASTLINE)
    ax.gridlines()

fig.savefig("hemispheres.png", bbox_inches="tight")

@ricitron
Copy link
Author

ricitron commented Feb 3, 2025

This works, thank you!

@ricitron ricitron closed this as completed Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants