Loading autocnet/fileio/io_gdal.py +2 −1 Original line number Original line Diff line number Diff line Loading @@ -392,7 +392,8 @@ class GeoDataset(object): lon, lat, _ = self.coordinate_transformation.TransformPoint(x, y) lon, lat, _ = self.coordinate_transformation.TransformPoint(x, y) except: except: lat = lon = None 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 return lat, lon Loading autocnet/graph/edge.py +6 −6 Original line number Original line Diff line number Diff line Loading @@ -228,11 +228,11 @@ class Edge(dict, MutableMapping): # Grab the full images, or handles # Grab the full images, or handles if tiled is True: if tiled is True: s_img = self.source.handle s_img = self.source.geodata d_img = self.destination.handle d_img = self.destination.geodata else: else: s_img = self.source.handle.read_array() s_img = self.source.geodata.read_array() d_img = self.destination.handle.read_array() d_img = self.destination.geodata.read_array() source_image = (matches.iloc[0]['source_image']) source_image = (matches.iloc[0]['source_image']) Loading Loading @@ -357,8 +357,8 @@ class Edge(dict, MutableMapping): The estimated area The estimated area """ """ source_geom = self.source.handle.pixel_polygon source_geom = self.source.geodata.pixel_polygon destination_geom = self.destination.handle.pixel_polygon destination_geom = self.destination.geodata.pixel_polygon # Project using the homography # Project using the homography vertices_to_project = destination_geom.vertices vertices_to_project = destination_geom.vertices Loading autocnet/graph/network.py +6 −3 Original line number Original line Diff line number Diff line Loading @@ -111,6 +111,7 @@ class CandidateGraph(nx.Graph): with open(filelist, 'r') as f: with open(filelist, 'r') as f: filelist = f.readlines() filelist = f.readlines() filelist = map(str.rstrip, filelist) filelist = map(str.rstrip, filelist) filelist = filter(None, filelist) # TODO: Reject unsupported file formats + work with more file formats # TODO: Reject unsupported file formats + work with more file formats if basepath: if basepath: Loading @@ -130,12 +131,14 @@ class CandidateGraph(nx.Graph): # Grab the footprints and test for intersection # Grab the footprints and test for intersection i_fp = i.footprint i_fp = i.footprint j_fp = j.footprint j_fp = j.footprint try: 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[i.file_name].append(j.file_name) adjacency_dict[j.file_name].append(i.file_name) adjacency_dict[j.file_name].append(i.file_name) except: # no geospatial information embedded in the images except: pass warnings.warn('No or incorrect geospatial information for {} and/or {}'.format(i, j)) return cls(adjacency_dict) return cls(adjacency_dict) Loading autocnet/graph/node.py +7 −7 Original line number Original line Diff line number Diff line Loading @@ -26,7 +26,7 @@ class Node(dict, MutableMapping): Name of the image, with extension Name of the image, with extension image_path : str image_path : str Relative or absolute PATH to the image Relative or absolute PATH to the image handle : object geodata : object File handle to the object File handle to the object keypoints : dataframe keypoints : dataframe With columns, x, y, and response With columns, x, y, and response Loading Loading @@ -59,10 +59,10 @@ class Node(dict, MutableMapping): """.format(self.node_id, self.image_name, self.image_path, """.format(self.node_id, self.image_name, self.image_path, self.nkeypoints, self.masks, self.__class__) self.nkeypoints, self.masks, self.__class__) @property @property def handle(self): def geodata(self): if not getattr(self, '_handle', None): if not getattr(self, '_geodata', None): self._handle = GeoDataset(self.image_path) self._geodata = GeoDataset(self.image_path) return self._handle return self._geodata @property @property def nkeypoints(self): def nkeypoints(self): Loading Loading @@ -123,7 +123,7 @@ class Node(dict, MutableMapping): The band to read, default 1 The band to read, default 1 """ """ array = self.handle.read_array(band=band) array = self.geodata.read_array(band=band) return bytescale(array) return bytescale(array) def get_keypoints(self, index=None): def get_keypoints(self, index=None): Loading Loading @@ -297,7 +297,7 @@ class Node(dict, MutableMapping): ratio : float ratio : float The ratio of convex hull area to total area. 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'): if not hasattr(self, '_keypoints'): raise AttributeError('Keypoints must be extracted already, they have not been.') raise AttributeError('Keypoints must be extracted already, they have not been.') Loading autocnet/graph/tests/test_network.py +2 −2 Original line number Original line Diff line number Diff line Loading @@ -72,8 +72,8 @@ class TestCandidateGraph(unittest.TestCase): self.assertEqual(self.graph.node[0].nkeypoints, loaded.node[0].nkeypoints) self.assertEqual(self.graph.node[0].nkeypoints, loaded.node[0].nkeypoints) self.assertEqual(self.graph.edge[0][1], loaded.edge[0][1]) self.assertEqual(self.graph.edge[0][1], loaded.edge[0][1]) a = self.graph.node[0].handle.read_array() a = self.graph.node[0].geodata.read_array() b = loaded.node[0].handle.read_array() b = loaded.node[0].geodata.read_array() np.testing.assert_array_equal(a, b) np.testing.assert_array_equal(a, b) os.remove('test_save.cg') os.remove('test_save.cg') Loading Loading
autocnet/fileio/io_gdal.py +2 −1 Original line number Original line Diff line number Diff line Loading @@ -392,7 +392,8 @@ class GeoDataset(object): lon, lat, _ = self.coordinate_transformation.TransformPoint(x, y) lon, lat, _ = self.coordinate_transformation.TransformPoint(x, y) except: except: lat = lon = None 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 return lat, lon Loading
autocnet/graph/edge.py +6 −6 Original line number Original line Diff line number Diff line Loading @@ -228,11 +228,11 @@ class Edge(dict, MutableMapping): # Grab the full images, or handles # Grab the full images, or handles if tiled is True: if tiled is True: s_img = self.source.handle s_img = self.source.geodata d_img = self.destination.handle d_img = self.destination.geodata else: else: s_img = self.source.handle.read_array() s_img = self.source.geodata.read_array() d_img = self.destination.handle.read_array() d_img = self.destination.geodata.read_array() source_image = (matches.iloc[0]['source_image']) source_image = (matches.iloc[0]['source_image']) Loading Loading @@ -357,8 +357,8 @@ class Edge(dict, MutableMapping): The estimated area The estimated area """ """ source_geom = self.source.handle.pixel_polygon source_geom = self.source.geodata.pixel_polygon destination_geom = self.destination.handle.pixel_polygon destination_geom = self.destination.geodata.pixel_polygon # Project using the homography # Project using the homography vertices_to_project = destination_geom.vertices vertices_to_project = destination_geom.vertices Loading
autocnet/graph/network.py +6 −3 Original line number Original line Diff line number Diff line Loading @@ -111,6 +111,7 @@ class CandidateGraph(nx.Graph): with open(filelist, 'r') as f: with open(filelist, 'r') as f: filelist = f.readlines() filelist = f.readlines() filelist = map(str.rstrip, filelist) filelist = map(str.rstrip, filelist) filelist = filter(None, filelist) # TODO: Reject unsupported file formats + work with more file formats # TODO: Reject unsupported file formats + work with more file formats if basepath: if basepath: Loading @@ -130,12 +131,14 @@ class CandidateGraph(nx.Graph): # Grab the footprints and test for intersection # Grab the footprints and test for intersection i_fp = i.footprint i_fp = i.footprint j_fp = j.footprint j_fp = j.footprint try: 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[i.file_name].append(j.file_name) adjacency_dict[j.file_name].append(i.file_name) adjacency_dict[j.file_name].append(i.file_name) except: # no geospatial information embedded in the images except: pass warnings.warn('No or incorrect geospatial information for {} and/or {}'.format(i, j)) return cls(adjacency_dict) return cls(adjacency_dict) Loading
autocnet/graph/node.py +7 −7 Original line number Original line Diff line number Diff line Loading @@ -26,7 +26,7 @@ class Node(dict, MutableMapping): Name of the image, with extension Name of the image, with extension image_path : str image_path : str Relative or absolute PATH to the image Relative or absolute PATH to the image handle : object geodata : object File handle to the object File handle to the object keypoints : dataframe keypoints : dataframe With columns, x, y, and response With columns, x, y, and response Loading Loading @@ -59,10 +59,10 @@ class Node(dict, MutableMapping): """.format(self.node_id, self.image_name, self.image_path, """.format(self.node_id, self.image_name, self.image_path, self.nkeypoints, self.masks, self.__class__) self.nkeypoints, self.masks, self.__class__) @property @property def handle(self): def geodata(self): if not getattr(self, '_handle', None): if not getattr(self, '_geodata', None): self._handle = GeoDataset(self.image_path) self._geodata = GeoDataset(self.image_path) return self._handle return self._geodata @property @property def nkeypoints(self): def nkeypoints(self): Loading Loading @@ -123,7 +123,7 @@ class Node(dict, MutableMapping): The band to read, default 1 The band to read, default 1 """ """ array = self.handle.read_array(band=band) array = self.geodata.read_array(band=band) return bytescale(array) return bytescale(array) def get_keypoints(self, index=None): def get_keypoints(self, index=None): Loading Loading @@ -297,7 +297,7 @@ class Node(dict, MutableMapping): ratio : float ratio : float The ratio of convex hull area to total area. 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'): if not hasattr(self, '_keypoints'): raise AttributeError('Keypoints must be extracted already, they have not been.') raise AttributeError('Keypoints must be extracted already, they have not been.') Loading
autocnet/graph/tests/test_network.py +2 −2 Original line number Original line Diff line number Diff line Loading @@ -72,8 +72,8 @@ class TestCandidateGraph(unittest.TestCase): self.assertEqual(self.graph.node[0].nkeypoints, loaded.node[0].nkeypoints) self.assertEqual(self.graph.node[0].nkeypoints, loaded.node[0].nkeypoints) self.assertEqual(self.graph.edge[0][1], loaded.edge[0][1]) self.assertEqual(self.graph.edge[0][1], loaded.edge[0][1]) a = self.graph.node[0].handle.read_array() a = self.graph.node[0].geodata.read_array() b = loaded.node[0].handle.read_array() b = loaded.node[0].geodata.read_array() np.testing.assert_array_equal(a, b) np.testing.assert_array_equal(a, b) os.remove('test_save.cg') os.remove('test_save.cg') Loading