Skip to content

Possibly an issue with get_lonlats() for robinson projection #232

@ninahakansson

Description

@ninahakansson

Code Sample, a minimal, complete, and verifiable piece of code

import matplotlib.pyplot as plt
from pyresample import load_area
import copy
import matplotlib

# Create colormap with high values red
my_cmap = copy.copy(matplotlib.cm.BrBG)
my_cmap.set_over('red', alpha=1)

# Create axis 
fig = plt.figure()
ax, ax2 = fig.subplots(nrows=2)

# Plot ortho longitudes
area_def = load_area('areas.yaml', 'ortho')
lon, lat = area_def.get_lonlats()
ax.imshow(lon,  vmin=-180, vmax=180, cmap=my_cmap)

#Plot robinson longitudes
area_def = load_area('areas.yaml', 'robinson')
lon, lat = area_def.get_lonlats()
ax2.imshow(lon,  vmin=-180, vmax=180, cmap=my_cmap)

# Save or show
plt.savefig('test_robinson.png')
plt.show()
ortho:
  description: Ortho globe
  projection:
    proj: ortho
    lon_0: 40.
    lat_0: -40.
    a: 6370997.0
  shape:
    height: 480
    width: 640
  area_extent:
    lower_left_xy: [-10000000, -10000000]
    upper_right_xy: [10000000, 10000000]

robinson:
  description: robinson
  projection:
    proj: robin
    lat_0: 0.0
    lon_0: 0.0
    ellps: WGS84
  shape:
    height: 480
    width: 640
  area_extent:
    lower_left_xy: [-17900000.0, -8800000.0]
    upper_right_xy: [17900000.0,  8800000.0]

Problem description

I am trying to resample and plot data on a Robinson projection.
However when plotting I get data also in the 4 corners. I have found away around it
and was thinking of adding an example to the docs.
But when using the ortho projection there is no problem with data in the corners.
Longitudes retrieved by get_lonlats() are for the ortho projection very large 10^30
in the corners outside the globe. However for the robinson projection they are not.

Expected Output

I would have expected longitude outside the globe to be very large or nan or nodata
for both the robinson and ortho projection. In the attached picture I expected red color outside the globe.

Actual Result, Traceback if applicable

test_robinson

Versions of Python, package at hand and relevant dependencies

Python 3.6.7
Pyresample 1.13.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions