Skip to content

Commit

Permalink
Get src_crs from last index position of gcps tuple
Browse files Browse the repository at this point in the history
Need to reproject from a proper source coordinate reference system (src_crs) instead of arbitrarily.
  • Loading branch information
weiji14 committed Sep 23, 2022
1 parent 66f3781 commit 4f656fe
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions stackstac/rio_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,23 +344,29 @@ def _open(self) -> ThreadsafeRioDataset:
)

# Only make a VRT if the dataset doesn't match the spatial spec we want
if (
hasattr(ds.crs, "to_epsg")
and self.spec.vrt_params
!= {
"crs": ds.crs.to_epsg(),
"transform": ds.transform,
"height": ds.height,
"width": ds.width,
}
) or ds.gcps is not None:
if hasattr(ds.crs, "to_epsg") and self.spec.vrt_params != {
"crs": ds.crs.to_epsg(),
"transform": ds.transform,
"height": ds.height,
"width": ds.width,
}:
with self.gdal_env.open_vrt:
vrt = WarpedVRT(
ds,
sharing=False,
resampling=self.resampling,
**self.spec.vrt_params,
)
elif ds.gcps is not None:
with self.gdal_env.open_vrt:
src_crs = ds.gcps[-1]
vrt = WarpedVRT(
ds,
src_crs=src_crs,
sharing=False,
resampling=self.resampling,
**self.spec.vrt_params,
)
else:
logger.info(f"Skipping VRT for {self.url!r}")
vrt = None
Expand Down

0 comments on commit 4f656fe

Please sign in to comment.