Closed echeipesh closed 5 years ago
Looks like an oversight / typo. It can also be the legacy from the experience of working with usual GDAL bindings, where derived warped datasets can loose some of the metadata.
The logic should be changed to
(sourceCRS, targetCRS) match {
case (Some(source), Some(target)) => if(source != target) List("-s_srs", source.toProj4String, "-t_srs", target.toProj4String)
else Nil
case (Some(source), _) => List("-s_srs", source.toProj4String)
case (_, Some(target)) => List("-t_srs", target.toProj4String)
}
And if tests won't fail, it is a good enough fix and it alings with an intuitive logic.
Resolved here https://github.com/locationtech/geotrellis/pull/3053
This is possibly an issue for clarification. When using
GDALRasterSource
andGDALWarpOptions
my expectation is that onlytargetCRS
would be required because that's how it works withgdalwarp
. However, I find that indeed bothsourceCRS
andtargetCRS
are required.Example (using geotrellis
3.0.0-SNAPSHOT
and latest version of this lib):scrolling to the right we can see that options are identical between just opening the file and providing
targetCRS
.I'm guessing this is for a reason, but I'm unclear on what the reason is. Also its a little counter-intuitive so I think its worth an issue. The intention here is to have a fully lazy reprojection because call to
GDALRasterSource.reproject
will query the underlying GDAL Dataset for the source CRS in order to set it in the options. This is specifically what I would like to avoid in a scenario I'm working on.https://github.com/geotrellis/geotrellis-contrib/blob/c67e35765df420f9e94169463749c81d6bd60802/gdal/src/main/scala/geotrellis/contrib/vlm/gdal/GDALRasterSource.scala#L115-L116