Reprojecting to Polar View

How to reproject global equirectangular data to an azimuthal equidistant (polar) projection.

This tutorial shows how to reproject a global equirectangular dataset to an azimuthal equidistant projection centered on an arbitrary point, using LambertAzimutal.

Scenario

We have a global OLCI daily PAR dataset at ~0.02° resolution (8640×4320) and want to reproject it to a focused polar-style view centered on a region of interest.

Step 1 — Open the source dataset

import xarray as xr

ds = xr.open_dataset("OLCI-AB-20230615__NEQ_8640__L3-dailyPAR.nc")

Step 2 — Create the projection

LambertAzimutal lets you pick any center point, radius, and rotation:

from quark.projection.lambertazimutal import LambertAzimutal

projection = LambertAzimutal(
    width=2000,
    height=2000,
    center_latitude=55.0,    # center of view
    center_longitude=-2.0,
    radius=60.0,             # angular radius in degrees
    rotation=25.0,           # clockwise rotation
)

For pole-centered views, use the convenience classes PolarNorth and PolarSouth:

from quark.projection.polar import PolarSouth

projection = PolarSouth(
    width=2000,
    height=2000,
    radius_deg=45.0,
    rotation_deg=0.0,
)

Step 3 — Configure supersampling

Supersampling improves coverage when the source footprint is large relative to the target grid. ConstantSuperSampler is the safer choice for irregular or global data:

from quark.supersampling import ConstantSuperSampler

supersampler = ConstantSuperSampler(
    factor=2,
    pixel_width="1km",
    project_center=True,
)

Step 4 — Run the aggregation

import numpy as np
from quark.aggregate import Aggregator

agg = Aggregator(
    projection=projection,
    datasets=[ds],
    variables=["daily_planar_PAR_(0+)"],
    supersampler=supersampler,
    return_counts=True,
    dtype=np.float32,
)

result = agg.compute()
result.to_netcdf("output_polar.nc")

Result

The output dataset contains the reprojected data on a 2000×2000 grid, with pixels outside the circular projection area set to fill values. A _count variable tracks how many source pixels contributed to each target pixel.

Tips

  • Use a smaller radius to zoom in on a region.
  • Adjust rotation to orient the view so a specific meridian points downward.
  • For high-precision accumulation, add sum_method="kahan" (requires numba).