From b981f16ae3b13baa979b503d3a939c229a387655 Mon Sep 17 00:00:00 2001 From: Anthony <schrapff.ant@gmail.com> Date: Fri, 7 Feb 2020 13:55:39 +0100 Subject: [PATCH] Polygon of modelgrid : Handle the case lon/lat = 0 --- ModelGrid.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ModelGrid.py b/ModelGrid.py index e081fc1..da503e6 100644 --- a/ModelGrid.py +++ b/ModelGrid.py @@ -96,10 +96,13 @@ def corners(indF, proj, istart, jstart, lon, lat) : polyll=proj.ijll(polyg) centll=proj.ijll([[istart+ij[0],jstart+ij[1]]])[0] # - allon.append([p[0] for p in polyll]) - allat.append([p[1] for p in polyll]) + lons = [p[0] if p[0]!=0 else 0.0000001 for p in polyll] + lats = [p[1] if p[1]!=0 else 0.0000001 for p in polyll] + + allon.append(lons) + allat.append(lats) # - sphpoly=polygon.SphericalPolygon.from_lonlat([p[0] for p in polyll], [p[1] for p in polyll], center=centll) + sphpoly=polygon.SphericalPolygon.from_lonlat(lons, lats, center=centll) # areas.append((sphpoly.area())*EarthRadius**2) cornerspoly.append(sphpoly) -- GitLab