Skip to content

Commit b71ea2e

Browse files
committed
Add natural earth raster mbtile example
1 parent e5a43b8 commit b71ea2e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import geoscript.geom.Bounds
2+
import geoscript.layer.Format
3+
import geoscript.layer.GeoTIFF
4+
import geoscript.layer.MBTiles
5+
import geoscript.layer.Raster
6+
import geoscript.layer.RasterTileRenderer
7+
import geoscript.layer.TileGenerator
8+
import geoscript.proj.Projection
9+
10+
import static geoscript.GeoScript.download
11+
import static geoscript.GeoScript.unzip
12+
13+
// Download data from natural earth
14+
File dataDir = new File("naturalearth")
15+
String url = "https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/50m/raster/NE2_50M_SR_W.zip"
16+
unzip(download(new URL(url), new File(dataDir, "NE2_50M_SR_W.zip"), overwrite: false))
17+
18+
// Raster Raster, crop and project
19+
Format format = new GeoTIFF(new File(dataDir, "NE2_50M_SR_W/NE2_50M_SR_W.tif"))
20+
Raster raster = format.read()
21+
Raster croppedRaster = raster.crop(new Bounds(-179.99, -85.0511, 179.99, 85.0511, new Projection("EPSG:4326")))
22+
Raster projectedRaster = croppedRaster.reproject(new Projection("EPSG:3857"))
23+
24+
// Generate Tiles
25+
TileGenerator generator = new TileGenerator(verbose: true)
26+
MBTiles mbtiles = new MBTiles(new File("NE2_50M_SR_W.mbtiles"), "NE2_50M_SR_W", "Natural Earth II with Shaded Relief and Water")
27+
RasterTileRenderer renderer = new RasterTileRenderer(projectedRaster)
28+
generator.generate(mbtiles, renderer, 0, 6)

0 commit comments

Comments
 (0)