Skip to content

Instantly share code, notes, and snippets.

@jericks
Last active June 6, 2018 03:43
Show Gist options
  • Save jericks/bb84e294b25afc89d6fda5a74dbe6237 to your computer and use it in GitHub Desktop.
Save jericks/bb84e294b25afc89d6fda5a74dbe6237 to your computer and use it in GitHub Desktop.
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