wradlib.georef.polar.spherical_to_polyvert

wradlib.georef.polar.spherical_to_polyvert#

wradlib.georef.polar.spherical_to_polyvert(r, phi, theta, site, *, crs=None)[source]#
wradlib.georef.polar.spherical_to_polyvert(obj: DataArray, **kwargs)
wradlib.georef.polar.spherical_to_polyvert(obj: Dataset, **kwargs)

Generate 3-D polygon vertices directly from spherical coordinates (r, phi, theta).

This is an alternative to centroid_to_polyvert which does not use centroids, but generates the polygon vertices by simply connecting the corners of the radar bins.

Both azimuth and range arrays are assumed to be equidistant and to contain only unique values. For further information refer to the documentation of spherical_to_xyz.

Parameters:
  • r (numpy.ndarray) – Array of ranges [m]; r defines the exterior boundaries of the range bins! (not the centroids). Thus, values must be positive!

  • phi (numpy.ndarray) – Array of azimuth angles containing values between 0° and 360°. The angles are assumed to describe the pointing direction fo the main beam lobe! The first angle can start at any values, but make sure the array is sorted continuously positively clockwise and the angles are equidistant. An angle if 0 degree is pointing north.

  • theta (float) – Elevation angle of scan

  • site (sequence) – the lon/lat/alt coordinates of the radar location

  • crs (osgeo.osr.SpatialReference) – Destination Projection

Returns:

  • output (numpy.ndarray) – A 3-d array of polygon vertices with shape(num_vertices, num_vertex_nodes, 2). The last dimension carries the xyz-coordinates either in aeqd or given crs.

  • aeqd (gdal:osgeo.aeqosr.SpatialReference) – only returned if crs is None

Examples

>>> import wradlib.georef as georef  # noqa
>>> import numpy as np
>>> from matplotlib import collections
>>> import matplotlib.pyplot as plt
>>> # define the polar coordinates and the site coordinates in lat/lon
>>> r = np.array([50., 100., 150., 200.]) * 1000
>>> az = np.array([0., 45., 90., 135., 180., 225., 270., 315.])
>>> el = 1.0
>>> site = (9.0, 48.0, 0)
>>> polygons, aeqd = georef.spherical_to_polyvert(r, az, el, site)
>>> # plot the resulting mesh
>>> fig = plt.figure()
>>> ax = fig.add_subplot(111)
>>> polycoll = collections.PolyCollection(polygons[...,:2], closed=True, facecolors='None')  # noqa
>>> ret = ax.add_collection(polycoll, autolim=True)
>>> plt.autoscale()
>>> plt.show()