From 1540146dc4dec0b6efe66fb3fccc606778ee1278 Mon Sep 17 00:00:00 2001 From: Adam Paquette <acp263@nau.edu> Date: Fri, 25 May 2018 12:32:29 -0700 Subject: [PATCH] Added latlon_corners function. --- plio/io/io_gdal.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/plio/io/io_gdal.py b/plio/io/io_gdal.py index 0d44659..ec87159 100644 --- a/plio/io/io_gdal.py +++ b/plio/io/io_gdal.py @@ -310,10 +310,8 @@ class GeoDataset(object): fp = self.footprint # If we have a footprint, do not worry about computing a lat/lon transform minx, maxx, miny, maxy = fp.GetEnvelope() - self._latlon_extent = [(minx, maxy), - (minx, miny), - (maxx, miny), - (maxx, maxy)] + self._latlon_extent = [(minx, miny), + (maxx, maxy)] else: self._latlon_extent = [] for x, y in self.xy_extent: @@ -322,6 +320,25 @@ class GeoDataset(object): self._latlon_extent.append((x,y)) return self._latlon_extent + @property + def latlon_corners(self): + if not getattr(self, '_latlon_corners', None): + if self.footprint: + fp = self.footprint + + minx, maxx, miny, maxy = fp.GetEnvelope() + self._latlon_corners = [(minx, maxy), + (minx, miny), + (maxx, miny), + (maxx, maxy)] + else: + self._latlon_corners = [] + for x, y in self.xy_corners: + x, y = self.pixel_to_latlon(x,y) + + self._latlon_corners.append((x,y)) + return self._latlon_corners + @property def xy_extent(self): return [(0, 0), -- GitLab