Skip to content

Instantly share code, notes, and snippets.

@jericks
Created November 18, 2014 03:34
Show Gist options
  • Save jericks/530a973f44af3947c04e to your computer and use it in GitHub Desktop.
Save jericks/530a973f44af3947c04e to your computer and use it in GitHub Desktop.
import geoscript.layer.*
import geoscript.geom.Bounds
import geoscript.proj.Projection
import javax.imageio.ImageIO
Projection proj = new Projection("EPSG:4326")
Bounds bounds = new Bounds(-180,-90,180,90, proj)
List imageSize = [1600, 800]
[
// OSM
new OSM(),
// Stamen Toner
new OSM("Stamen Toner", [
"http://a.tile.stamen.com/toner",
"http://b.tile.stamen.com/toner",
"http://c.tile.stamen.com/toner",
"http://d.tile.stamen.com/toner"
]),
// Stamen Toner-lite
new OSM("Stamen Toner Lite", [
"http://a.tile.stamen.com/toner-lite",
"http://b.tile.stamen.com/toner-lite",
"http://c.tile.stamen.com/toner-lite",
"http://d.tile.stamen.com/toner-lite"
]),
// Stamen Watercolor
new OSM("Stamen Watercolor", [
"http://a.tile.stamen.com/watercolor",
"http://b.tile.stamen.com/watercolor",
"http://c.tile.stamen.com/watercolor",
"http://d.tile.stamen.com/watercolor"
]),
// Open MapQuest Street Map
new OSM("MapQuest Street Map",[
"http://otile1.mqcdn.com/tiles/1.0.0/map",
"http://otile2.mqcdn.com/tiles/1.0.0/map",
"http://otile3.mqcdn.com/tiles/1.0.0/map",
"http://otile4.mqcdn.com/tiles/1.0.0/map"
]),
// Open MapQuest Satellite Map
new OSM("MapQuest Satellite Map", [
"http://otile1.mqcdn.com/tiles/1.0.0/sat",
"http://otile2.mqcdn.com/tiles/1.0.0/sat",
"http://otile3.mqcdn.com/tiles/1.0.0/sat",
"http://otile4.mqcdn.com/tiles/1.0.0/sat"
])
].each { ImageTileLayer tileLayer ->
Raster raster = tileLayer.getRaster(tileLayer.tiles(3)).reproject(proj).resample(bbox: bounds, size: imageSize)
ImageIO.write(raster.image, "png", new File("${tileLayer.name}.png"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment