Skip to content

Commit

Permalink
Merge pull request #708 from azavea/lf/ident-transform
Browse files Browse the repository at this point in the history
Fix issue with saving semseg predictions for non-georeferenced imagery
  • Loading branch information
lewfish committed Mar 6, 2019
2 parents 9f38cc9 + ef33271 commit 90f4c5d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Expand Up @@ -29,6 +29,7 @@ Raster Vision 0.8.2
Bug Fixes
^^^^^^^^^
- Fixed issue with saving semseg predictions for non-georeferenced imagery `#708 <https://github.com/azavea/raster-vision/pull/708>`_
- Fixed issue with handling width > height in semseg eval `#627 <https://github.com/azavea/raster-vision/pull/627>`_
- Fixed issue with experiment configs not setting key names correctly `#523 <https://github.com/azavea/raster-vision/pull/576>`_
- Fixed issue with Raster Sources that have channel order `#503 <https://github.com/azavea/raster-vision/pull/576>`_
Expand Down
5 changes: 3 additions & 2 deletions rastervision/data/crs_transformer/crs_transformer.py
Expand Up @@ -3,9 +3,10 @@ class CRSTransformer(object):
Each transformer is associated with a particular RasterSource."""

def __init__(self, image_crs=None, map_crs=None):
def __init__(self, image_crs=None, map_crs=None, transform=None):
self.image_crs = image_crs
self.map_crs = map_crs
self.transform = transform

def map_to_pixel(self, map_point):
"""Transform point from map to pixel-based coordinates.
Expand Down Expand Up @@ -36,4 +37,4 @@ def get_map_crs(self):
return self.map_crs

def get_affine_transform(self):
raise NotImplementedError()
return self.transform
Expand Up @@ -16,11 +16,10 @@ def __init__(self, transform, image_crs, map_crs='epsg:4326'):
image_dataset: Rasterio DatasetReader
map_crs: CRS code
"""
self.transform = transform
self.map_proj = pyproj.Proj(init=map_crs)
self.image_proj = pyproj.Proj(init=image_crs)

super().__init__(image_crs, map_crs)
super().__init__(image_crs, map_crs, transform)

def map_to_pixel(self, map_point):
"""Transform point from map to pixel-based coordinates.
Expand Down
Expand Up @@ -85,9 +85,7 @@ def save(self, labels):
local_path = get_local_path(self.uri, self.tmp_dir)
make_dir(local_path, use_dirname=True)

# TODO: this only works if crs_transformer is RasterioCRSTransformer.
# Need more general way of computing transform for the more general case.
transform = self.crs_transformer.transform
transform = self.crs_transformer.get_affine_transform()
crs = self.crs_transformer.get_image_crs()

band_count = 1
Expand Down

0 comments on commit 90f4c5d

Please sign in to comment.