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

Clipping issue with Geostationary/NearsidePerspective #1144

Closed
dopplershift opened this issue Oct 12, 2018 · 3 comments
Closed

Clipping issue with Geostationary/NearsidePerspective #1144

dopplershift opened this issue Oct 12, 2018 · 3 comments

Comments

@dopplershift
Copy link
Contributor

I received this report from a user who was concerned by the points outside the circle of the globe:

import numpy as np
import cartopy.crs as ccrs
import cartopy.feature as cfeature
import matplotlib.pyplot as plt

lons, lats = np.meshgrid(np.linspace(0, 360, 100), np.linspace(-90, 90, 100))

data_projection = ccrs.Geodetic()
map_projection1 = ccrs.NearsidePerspective(central_longitude=0.0, central_latitude=0.0,     
                                           satellite_height=700000)

map_projection2 = ccrs.Geostationary(central_longitude=0.0, satellite_height=700000)

map_projections = [map_projection1, map_projection2]

for map_projection in map_projections:
    fig = plt.figure(figsize=(12, 8))
    ax = fig.add_subplot(1, 1, 1, projection=map_projection)

    # add some common geographic features
    ax.coastlines(resolution='10m', color='black')
    ax.add_feature(cfeature.STATES, edgecolor='black')
    ax.add_feature(cfeature.BORDERS)

    # add some lat/lon gridlines
    ax.gridlines()
    ax.set_global()
    ax.scatter(lons, lats, transform=data_projection)

produces these images for me.
NearsidePerspective:
cartopy-projection-bug-image2

Geostationary:
cartopy-projection-bug-image

I'm a little confused at the moment as to why these are so different as well.

@dopplershift dopplershift self-assigned this Oct 12, 2018
@QuLogic
Copy link
Member

QuLogic commented Oct 12, 2018

Probably related to #1081.

@dopplershift
Copy link
Contributor Author

Nope, the problem in #1081 was fixed by matplotlib >=2.2.3. The problem here persists for me with current master and latest matplotlib release (currently 3.0.2).

@dopplershift
Copy link
Contributor Author

So there are a few things going on here. First, Geostationary != NearSidePerspective@equator. Geostationary uses h*scan_angle for the projection coordinates, while Near Side Perspective (NSP) uses x/y distances on a plane tangent to the Earth right below the perspective point.

This implies that the shape of the boundary for NSP should be a circle, but we're using a slightly incorrect formula (PR incoming). I should also note that Proj's nsper only works on spheres, so I'll also warn about that.

For Geostationary, the shape of the boundary is more complicated than a circle. This is why we see points outside our boundary; our boundary should extend out further--more of a heavily rounded square I think. For the life of me, though, I can't manage to generate a sane formula, probably because it involves some horrific math on a sphere. In practice, it's not really a big deal, since the only data that actually comes in that projection is at a height of 35e6 m, at which point a circle is a fine approximation.

@dopplershift dopplershift added this to the 0.17 milestone Nov 15, 2018
dopplershift added a commit to dopplershift/cartopy that referenced this issue Nov 15, 2018
This refactors the Geostationary and NearSidePerspective projections so
that they can individually set up their boundary, limits, etc. Doing so
allows fixing the incorrect boundary being set for NearSidePerspective.
The two projections can't share the math for the boundary because they
are fundamentally different coordinate systems.
dopplershift added a commit to dopplershift/cartopy that referenced this issue Nov 15, 2018
This refactors the Geostationary and NearSidePerspective projections so
that they can individually set up their boundary, limits, etc. Doing so
allows fixing the incorrect boundary being set for NearSidePerspective.
The two projections can't share the math for the boundary because they
are fundamentally different coordinate systems.
QuLogic added a commit that referenced this issue Nov 16, 2018
Fix up the satellite projections (Fixes #1144)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants