Loading .travis.yml +3 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ sudo: false branches: only: - master os: - linux - osx Loading Loading @@ -35,7 +36,8 @@ before_install: install: - conda config --add channels conda-forge - conda install -q gdal h5py pandas sqlalchemy pyyaml networkx affine protobuf scipy pvl - conda install -c conda-forge libgdal gdal numpy - conda install -q h5py pandas sqlalchemy pyyaml networkx affine protobuf scipy pvl # Development installation - conda install -q pytest pytest-cov sh coveralls nbsphinx Loading plio/io/io_gdal.py +33 −9 Original line number Diff line number Diff line Loading @@ -184,7 +184,9 @@ class GeoDataset(object): top left y, y-rotation, n-s pixel resolution] """ if not getattr(self, '_geotransform', None): if self.footprint: try: self._geotransform = self.dataset.GetGeoTransform() except: coords = json.loads(self.footprint.ExportToJson())['coordinates'][0][0] ul, ur, lr, ll = geofuncs.find_four_corners(coords) Loading @@ -196,8 +198,7 @@ class GeoDataset(object): yskew = (ur[1] - ystart) / xsize yscale = (ll[1] - ystart) / ysize self._geotransform = [xstart, xscale, xskew, ystart, yskew, yscale] else: self._geotransform = self.dataset.GetGeoTransform() return self._geotransform @property Loading Loading @@ -226,6 +227,7 @@ class GeoDataset(object): return self._unit_type @property <<<<<<< HEAD def north_up(self): return True if self.footprint: Loading @@ -234,6 +236,8 @@ class GeoDataset(object): return True @property ======= >>>>>>> 2f82f6bf36ebf5124f2f0448f824f3eb14f05e64 def spatial_reference(self): if not getattr(self, '_srs', None): self._srs = osr.SpatialReference() Loading Loading @@ -290,6 +294,25 @@ class GeoDataset(object): except: self._footprint = None try: # Get the lat lon corners lat = [i[0] for i in self.latlon_corners] lon = [i[1] for i in self.latlon_corners] # Compute a ogr geometry for the tiff which # provides leverage for overlaps ring = ogr.Geometry(ogr.wkbLinearRing) for point in [*zip(lon, lat)]: ring.AddPoint(*point) ring.AddPoint(lon[0], lat[0]) poly = ogr.Geometry(ogr.wkbPolygon) poly.AddGeometry(ring) poly.FlattenTo2D() self._footprint = poly except: self._footprint = None return self._footprint @property Loading @@ -314,11 +337,13 @@ class GeoDataset(object): self._latlon_extent = [(minx, miny), (maxx, maxy)] else: # Attempt to compute a basic bounding box footprint self._latlon_extent = [] for x, y in self.xy_extent: x, y = self.pixel_to_latlon(x,y) self._latlon_extent.append((x,y)) xy_extent = self.xy_extent maxlon, minlat = self.pixel_to_latlon(*xy_extent[0]) minlon, maxlat = self.pixel_to_latlon(*xy_extent[1]) self._latlon_extent.append((minlat, minlon)) self._latlon_extent.append((maxlat, maxlon)) return self._latlon_extent @property Loading Loading @@ -518,8 +543,7 @@ class GeoDataset(object): if ystart + ycount > ymax: ycount = ymax - ystart array = band.ReadAsArray(xstart, ystart, xcount, ycount).astype(dtype) #if self.north_up == False: # array = np.flipud(array) return array def compute_overlap(self, geodata, **kwargs): Loading plio/io/tests/test_io_gdal.py +14 −1 Original line number Diff line number Diff line Loading @@ -50,7 +50,12 @@ class TestMercator(unittest.TestCase): def test_latlon_extent(self): self.assertEqual(self.dataset.latlon_extent, [(55.33228905180849, 0.0), (-55.3322890518085, 179.96751473604124)]) def test_latlon_corners(self): self.assertEqual(self.dataset.latlon_corners, [(55.33228905180849, 0.0), (-55.3322890518085, 179.96751473604124)]) """ def test_spheroid(self): sphere = self.dataset.spheroid self.assertAlmostEqual(sphere[0], 3396190.0, 6) Loading Loading @@ -111,6 +116,14 @@ class TestLambert(unittest.TestCase): def test_get_xy_extent(self): self.assertEqual(self.dataset.xy_extent, [(0, 0), (239, 275)]) def test_latlon_extent(self): self.assertEqual(self.dataset.latlon_extent, [(-29.721669024636785, 37.834604457982444), (69.44231975603968, 69.99086737565507)]) def test_latlon_corners(self): self.assertEqual(self.dataset.latlon_corners, [(-29.721669024636785, 69.99086737565507), (-29.721669024636785, 37.834604457982444), (69.44231975603968, 37.834604457982444), (69.44231975603968, 69.99086737565507)]) def test_get_no_data_value(self): self.assertEqual(self.dataset.no_data_value, 0.0) Loading Loading
.travis.yml +3 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ sudo: false branches: only: - master os: - linux - osx Loading Loading @@ -35,7 +36,8 @@ before_install: install: - conda config --add channels conda-forge - conda install -q gdal h5py pandas sqlalchemy pyyaml networkx affine protobuf scipy pvl - conda install -c conda-forge libgdal gdal numpy - conda install -q h5py pandas sqlalchemy pyyaml networkx affine protobuf scipy pvl # Development installation - conda install -q pytest pytest-cov sh coveralls nbsphinx Loading
plio/io/io_gdal.py +33 −9 Original line number Diff line number Diff line Loading @@ -184,7 +184,9 @@ class GeoDataset(object): top left y, y-rotation, n-s pixel resolution] """ if not getattr(self, '_geotransform', None): if self.footprint: try: self._geotransform = self.dataset.GetGeoTransform() except: coords = json.loads(self.footprint.ExportToJson())['coordinates'][0][0] ul, ur, lr, ll = geofuncs.find_four_corners(coords) Loading @@ -196,8 +198,7 @@ class GeoDataset(object): yskew = (ur[1] - ystart) / xsize yscale = (ll[1] - ystart) / ysize self._geotransform = [xstart, xscale, xskew, ystart, yskew, yscale] else: self._geotransform = self.dataset.GetGeoTransform() return self._geotransform @property Loading Loading @@ -226,6 +227,7 @@ class GeoDataset(object): return self._unit_type @property <<<<<<< HEAD def north_up(self): return True if self.footprint: Loading @@ -234,6 +236,8 @@ class GeoDataset(object): return True @property ======= >>>>>>> 2f82f6bf36ebf5124f2f0448f824f3eb14f05e64 def spatial_reference(self): if not getattr(self, '_srs', None): self._srs = osr.SpatialReference() Loading Loading @@ -290,6 +294,25 @@ class GeoDataset(object): except: self._footprint = None try: # Get the lat lon corners lat = [i[0] for i in self.latlon_corners] lon = [i[1] for i in self.latlon_corners] # Compute a ogr geometry for the tiff which # provides leverage for overlaps ring = ogr.Geometry(ogr.wkbLinearRing) for point in [*zip(lon, lat)]: ring.AddPoint(*point) ring.AddPoint(lon[0], lat[0]) poly = ogr.Geometry(ogr.wkbPolygon) poly.AddGeometry(ring) poly.FlattenTo2D() self._footprint = poly except: self._footprint = None return self._footprint @property Loading @@ -314,11 +337,13 @@ class GeoDataset(object): self._latlon_extent = [(minx, miny), (maxx, maxy)] else: # Attempt to compute a basic bounding box footprint self._latlon_extent = [] for x, y in self.xy_extent: x, y = self.pixel_to_latlon(x,y) self._latlon_extent.append((x,y)) xy_extent = self.xy_extent maxlon, minlat = self.pixel_to_latlon(*xy_extent[0]) minlon, maxlat = self.pixel_to_latlon(*xy_extent[1]) self._latlon_extent.append((minlat, minlon)) self._latlon_extent.append((maxlat, maxlon)) return self._latlon_extent @property Loading Loading @@ -518,8 +543,7 @@ class GeoDataset(object): if ystart + ycount > ymax: ycount = ymax - ystart array = band.ReadAsArray(xstart, ystart, xcount, ycount).astype(dtype) #if self.north_up == False: # array = np.flipud(array) return array def compute_overlap(self, geodata, **kwargs): Loading
plio/io/tests/test_io_gdal.py +14 −1 Original line number Diff line number Diff line Loading @@ -50,7 +50,12 @@ class TestMercator(unittest.TestCase): def test_latlon_extent(self): self.assertEqual(self.dataset.latlon_extent, [(55.33228905180849, 0.0), (-55.3322890518085, 179.96751473604124)]) def test_latlon_corners(self): self.assertEqual(self.dataset.latlon_corners, [(55.33228905180849, 0.0), (-55.3322890518085, 179.96751473604124)]) """ def test_spheroid(self): sphere = self.dataset.spheroid self.assertAlmostEqual(sphere[0], 3396190.0, 6) Loading Loading @@ -111,6 +116,14 @@ class TestLambert(unittest.TestCase): def test_get_xy_extent(self): self.assertEqual(self.dataset.xy_extent, [(0, 0), (239, 275)]) def test_latlon_extent(self): self.assertEqual(self.dataset.latlon_extent, [(-29.721669024636785, 37.834604457982444), (69.44231975603968, 69.99086737565507)]) def test_latlon_corners(self): self.assertEqual(self.dataset.latlon_corners, [(-29.721669024636785, 69.99086737565507), (-29.721669024636785, 37.834604457982444), (69.44231975603968, 37.834604457982444), (69.44231975603968, 69.99086737565507)]) def test_get_no_data_value(self): self.assertEqual(self.dataset.no_data_value, 0.0) Loading