With Google Maps Engine (GME) closing down next year, GME users are looking for alternatives. CARTO offers a great solution for mapping vector data, but some users also have raster imagery they use in maps. For those users, here’s a reliable and simple way to keep hosting imagery in the Google cloud after GME shuts down.
In brief, the steps are:
If you have existing raster data already loaded in Google Maps Engine (GME), you can download the original files and reprocess them using our technique. Log into your GME account, and navigate to your raster data source. There is a “Download original files” link in the details page of each raster data source in GME.
Once you have downloaded the original data, you are ready to start creating a tile cache.
To just follow along with this tutorial, download a sample image file, from an open data site. The City of Kamloops has an accessible collection, for example.
To generate a tile cache, we will use the gdal2tiles.py program, which comes with the GDAL image processing library. You can get
gdal2tiles.py for your platform by:
Once you have the program installed, generating a tile cache is a one-line command:
gdal2tiles.py <your_input_file> <your_tiles_directory>
So for example:
gdal2tiles.py 5255C.tif kamloops
gdal2tiles.py program is pretty good, but it has a couple shortcomings for bulk tile creation:
There is an enhanced version, gdal2tilesp.py that fixes both limitations. Once you have installed GDAL as described above, you should be able to just download gdal2tilesp.py and copy it next to the original version to access the new functionality.
gdal2tilesp.py on 4 CPUs and outputting JPEG tiles (which makes sense for imagery) looks like this:
gdal2tilesp.py --format=JPEG --processes=4 5255C.tif kamloops
The parallel process is faster than the single process, and more importantly the JPEG storage is much smaller than PNG storage for imagery.
The first time you upload to Google Cloud Storage, you will need to do a bit of setup:
Authorize Google Cloud SDK to access your Google Account, by running the following command:
gcloud auth login --project YOUR_PROJECT
Now you are ready to upload the tile cache.
Navigate to your tile cache directory and run the upload command, which will recursively copy all the tiles up into the cloud. Note that you will need both your project name and bucket name to run the command.
gsutil -m \ -h 'Cache-Control:public,max-age:31536000,x-goog-project-id:YOUR_PROJECT' \ cp -a public-read -R ./YOUR_TILES_DIR gs://YOUR_BUCKET/*
Now that the tiles are stored in the cloud, you can easily add them to our CARTO maps as a new basemap.
Use the XYZ tab and enter in the URL for your tile cache. If you’ve followed the instructions above, it should be formatted like this:
Here’s an example of the Kamloops aerial basemap with some zoning data overlaid on top. Crisp local imagery and great registration to the overlaid data too!
Any raster input file that GDAL can read (and that is most of them) can be converted into a tiled basemap using this simple technique.
The same technique can also be used along with GDAL Virtual Raster Table driver and the gdalbuildvrt tool to convert large collections of multiple input source rasters into tile caches ready for upload into the Google Cloud. More on that in a future post.
Today, at the Spatial Data Science Conference, we presented the recently launched Data Observatory 2.0 (DO). A new platform to discover and consume location data for spatia...News
Data is an essential ingredient for spatial analysis—which is predicated on access to your own data, plus useful third-party data. In the end, spatial analysis is about put...News
Please fill out the below form and we'll be in touch real soon.