2

I have a bunch of geotiffs without SRS. It is possible to fix the SRS using GDAL command:

gdal_translate -a_srs EPSG:25832 srcfile targetfile

How can I replace the GDAL command using geotrellis code ?

metasim
  • 4,793
  • 3
  • 46
  • 70
Viliam Simko
  • 1,711
  • 17
  • 31

1 Answers1

4
import geotrellis.proj4._
import geotrellis.raster.io.geotiff._

val fileName: String = ???
val tif = SinglebandGeoTiff(fileName)
val targetCrs = CRS.fromName("EPSG:25832”)
val reprojected = tif.projectedRaster.reproject(targetCrs)
GeoTiff(reprojected.raster,  reprojected.crs).write("/Users/eugene/reprojected.tif")

You can use MultibandGeoTiff if you're working with multiple bands.

Eugene Cheipesh
  • 373
  • 1
  • 9
  • 1
    @ViliamSimko take a look into https://github.com/geotrellis/geotrellis/pull/1697 (i double checked that tiifs without crs would be loaded as tiffs with LatLng), however you can specify neccesary crs during the ingest process, can you check this new feature? If no, any problem tile example would be great! – DaunnC Nov 06 '16 at 13:40
  • @ViliamSimko looks like yes, it _reprojects_, not assignes crs; – DaunnC Nov 06 '16 at 13:40