Commit f65e7283 authored by Adam Paquette's avatar Adam Paquette
Browse files

Merge remote-tracking branch 'upstream/master'

parents ed446ee5 4af19d4b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -392,7 +392,8 @@ class GeoDataset(object):
            lon, lat, _ = self.coordinate_transformation.TransformPoint(x, y)
        except:
            lat = lon = None
            warnings.warn('Unable to compute pixel to geographic conversion without projection information.')
            warnings.warn('Unable to compute pixel to geographic conversion without '
                          'projection information for {}'.format(self.base_name))

        return lat, lon

+6 −6
Original line number Diff line number Diff line
@@ -228,11 +228,11 @@ class Edge(dict, MutableMapping):

        # Grab the full images, or handles
        if tiled is True:
            s_img = self.source.handle
            d_img = self.destination.handle
            s_img = self.source.geodata
            d_img = self.destination.geodata
        else:
            s_img = self.source.handle.read_array()
            d_img = self.destination.handle.read_array()
            s_img = self.source.geodata.read_array()
            d_img = self.destination.geodata.read_array()

        source_image = (matches.iloc[0]['source_image'])

@@ -357,8 +357,8 @@ class Edge(dict, MutableMapping):
               The estimated area
        """

        source_geom = self.source.handle.pixel_polygon
        destination_geom = self.destination.handle.pixel_polygon
        source_geom = self.source.geodata.pixel_polygon
        destination_geom = self.destination.geodata.pixel_polygon

        # Project using the homography
        vertices_to_project = destination_geom.vertices
+6 −3
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ class CandidateGraph(nx.Graph):
            with open(filelist, 'r') as f:
                filelist = f.readlines()
                filelist = map(str.rstrip, filelist)
                filelist = filter(None, filelist)

        # TODO: Reject unsupported file formats + work with more file formats
        if basepath:
@@ -130,12 +131,14 @@ class CandidateGraph(nx.Graph):
            # Grab the footprints and test for intersection
            i_fp = i.footprint
            j_fp = j.footprint

            try:
                if i_fp.Intersects(j_fp):
                if j_fp and i_fp and i_fp.Intersects(j_fp):
                    adjacency_dict[i.file_name].append(j.file_name)
                    adjacency_dict[j.file_name].append(i.file_name)
            except: # no geospatial information embedded in the images
                pass
            except:
                warnings.warn('No or incorrect geospatial information for {} and/or {}'.format(i, j))

        return cls(adjacency_dict)


+7 −7
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ class Node(dict, MutableMapping):
                 Name of the image, with extension
    image_path : str
                 Relative or absolute PATH to the image
    handle : object
    geodata : object
             File handle to the object
    keypoints : dataframe
                With columns, x, y, and response
@@ -59,10 +59,10 @@ class Node(dict, MutableMapping):
        """.format(self.node_id, self.image_name, self.image_path,
                   self.nkeypoints, self.masks, self.__class__)
    @property
    def handle(self):
        if not getattr(self, '_handle', None):
            self._handle = GeoDataset(self.image_path)
        return self._handle
    def geodata(self):
        if not getattr(self, '_geodata', None):
            self._geodata = GeoDataset(self.image_path)
        return self._geodata

    @property
    def nkeypoints(self):
@@ -123,7 +123,7 @@ class Node(dict, MutableMapping):
               The band to read, default 1
        """

        array = self.handle.read_array(band=band)
        array = self.geodata.read_array(band=band)
        return bytescale(array)

    def get_keypoints(self, index=None):
@@ -297,7 +297,7 @@ class Node(dict, MutableMapping):
        ratio : float
                The ratio of convex hull area to total area.
        """
        ideal_area = self.handle.pixel_area
        ideal_area = self.geodata.pixel_area
        if not hasattr(self, '_keypoints'):
            raise AttributeError('Keypoints must be extracted already, they have not been.')

+2 −2
Original line number Diff line number Diff line
@@ -72,8 +72,8 @@ class TestCandidateGraph(unittest.TestCase):
        self.assertEqual(self.graph.node[0].nkeypoints, loaded.node[0].nkeypoints)
        self.assertEqual(self.graph.edge[0][1], loaded.edge[0][1])

        a = self.graph.node[0].handle.read_array()
        b = loaded.node[0].handle.read_array()
        a = self.graph.node[0].geodata.read_array()
        b = loaded.node[0].geodata.read_array()
        np.testing.assert_array_equal(a, b)

        os.remove('test_save.cg')
Loading