Last active
June 6, 2018 03:43
-
-
Save jericks/bb84e294b25afc89d6fda5a74dbe6237 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File file = new File("earth.tif") | |
GeoTIFF geotiff = new GeoTIFF(file) | |
Raster raster = geotiff.read("earth") | |
File arcGridFile = new File("earth.asc") | |
ArcGrid arcGrid = new ArcGrid(arcGridFile) | |
arcGrid.write(raster) | |
Raster arcGridRaster = arcGrid.read("earth") | |
arcGridRaster.eachCell {double value, double x, double y -> | |
double newValue = value + 100 | |
arcGridRaster.setValue([x,y], newValue) | |
assert newValue == arcGridRaster.getValue([x,y]) | |
} | |
File arcGridFile2 = new File("earth_add.asc") | |
ArcGrid arcGrid2 = new ArcGrid(arcGridFile2) | |
arcGrid2.write(arcGridRaster) | |
Raster arcGridRasterAdd = arcGrid2.read("earth_add") | |
arcGridRaster.eachCell {double value, double x, double y -> | |
println "${x},${y} ${value} = ${arcGridRasterAdd.getValue([x,y])}" | |
assert value == arcGridRasterAdd.getValue([x,y]) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment