Now that you've finished designing your map and you've published it to the server, you're ready to start creating the cache of map tiles. As an advance notice, you should plan at least one continuous hour to work on this page of the lesson.
In this lesson, you'll learn how to create tiles using ArcGIS Server. However, tiles can be created using many other types of GIS and mapping utilities. Mapnik is an example, which is used to create the tiles for OpenStreetMap.
Map tiling has become so popular that the Open Geospatial Consortium (OGC) has even released the Web Map Tiling Standard (WMTS) detailing an open specification on how mapping web services should expose their tile sets. ArcGIS Server services that have a tile cache can respond to WMTS-formatted requests.
Creating a tile cache with ArcGIS Server
When you publish a map service or image service in ArcGIS Server, you can define whether it will have a cache and what the cache properties will be. You can either build the tiles right at the time the service is published, or you can instigate the tile building later using geoprocessing tools like Manage Map Server Cache Tiles. Building the tiles at publish time is appropriate for smaller cache jobs, and that's what we'll do in this lesson.
- Make sure you are logged in to your EC2 instance and displaying StMap_Template_LittleRock_WebM.mxd in ArcMap. In other words, you should be at the exact same point where you left off in the previous section of the lesson.
- Click File > Share As > Service, and start the process of publishing a map service named LittleRock using the pattern from previous lessons. Stop when you reach the Service Editor window.
- Click the Parameters tab of the Service Editor, and set the anti-aliasing level to Fast for this lesson.
When making cache tiles, you should typically use anti-aliasing to make them appear as nice as possible. However, each level of anti-aliasing quality can increase the time required to build the cache, sometimes by orders of magnitude. The Fast level is a good compromise for the purpose of this lesson.
- Click the Caching tab of the Service Editor, and choose to draw this map service Using tiles from a cache.
This is where you'll define all the properties of your cache. You've already set up your map to use the Web Mercator projection, and you've ensured the map is designed for the scales of the ArcGIS Online / Bing Maps / Google Maps tiling scheme. Therefore, you can take the default value ArcGIS Online / Bing Maps / Google Maps in the Tiling Scheme drop-down. You can think of a tiling scheme as defining an empty, three dimensional "container" of tiles. The three dimensions are the scale levels, the width of the map, and the height of the map. At this point, you need to selectively fill up that container with tiles. You won't create tiles at all the scales, and you won't create them across the entire width and height of the map. Doing so wouldn't make sense, since your map does not have data or symbols for the extreme large and small scales in the ArcGIS Online / Bing Maps / Google Maps tiling scheme. Also, you are not interested in creating tiles outside the Little Rock urban area. If you wanted to use your own set of scales or a projection other than Web Mercator, you could use the Generate Map Server Cache Tiling Scheme tool to make your own tiling scheme file (which is just simple XML), and then you could browse to it by picking A tiling scheme file from this drop-down.
- Examine the Levels of Detail slider, but leave the defaults going from 1,155,581 - 1:4,513. Although there are 20 scales in your tiling scheme, some scales may be way too detailed or too far zoomed out to be of use. As the service publisher, you can use these sliders to define the range of scales at which people will be allowed to create tiles for this service. ArcMap set these defaults by examining the scale ranges and the extent of data in your map document.
- Click the Advanced Settings tab in the left menu. Some of these settings are not really advanced, they are fundamental.
- In the Area of interest to cache drop-down, choose Import from a feature class and browse to the CacheArea feature class you digitized in the previous section of the lesson. This will cause tiles to only be created around the city of LittleRock. By default, ArcGIS Server caches the full extent rectangle of the map document, but this can be wildly inappropriate if your map has a lot of peripheral data in it or if you are caching a non-rectangular geography like Florida (you don't need a bunch of tiles created out in the Gulf of Mexico). Always consider masking your job to a feature class boundary using this option. Also, any time you run the Manage Map Server Cache Tiles tool manually, you should consider using a feature class to define the tile creation area. The feature class you define here in the Advanced Settings tab only gets used when you build the tiles automatically at publish time, which we will do.
- Change the Tile format to MIXED and set the Compression level to 90. The image format you select for your tiles can affect your map appearance, the amount of space it takes to store your cache, and the amount of time it takes to download your tiles to the browser. The MIXED format uses the compressed JPEG format in the middle of the cache while using the larger but transparency-supporting PNG32 on the periphery where the map background is detected. This allows you to overlay your cache on top of other caches, while getting a relatively small size of cache on disk. The Compression setting refers to the amount of compression applied to the JPEGs, where 0 represents the most compression (but poorest quality) and 100 represents the least. In a vector map like this one, you need to keep the quality setting relatively high to reduce fuzziness around lines and labels.There are many guidelines about image format in the Esri help, including discussion about a new PNG format that can optimize the storage space for a cache (but takes longer to generate). See the "Tile format" section of Available map cache properties.
- Switch back to the Caching tab. At this time, you're going to make a key decision about whether to create the cache tiles right away at the time you publish, or create them later in phases by running the Manage Map Server Cache Tiles tool. For smaller jobs that can be completed in less than a few hours, it may be appropriate to build the tiles right away. One way you can determine the size of your job is to run the Calculate Cache Size utility, which builds some sample tiles and attempts to extrapolate the size of your cache. It will use the rectangular extent of your CacheArea feature class to perform this estimation.
- Click Calculate Cache Size, set the Estimate Quality to Best, and click Start. Notice that sample tiles are being built at each scale level, and you get an estimate range based on the size of the sample tiles and the area of your cache. The estimate you see will vary somewhat from the image below, based on the size of your CacheArea polygon and the sample tiles created.
- Close the Calculate Cache Size utility, then go ahead and click Publish. You see the familiar message about the service being packaged and published, but then you should eventually also see a message that the tiles are being created.
- In the Catalog window of ArcMap, right-click your service and click View Cache Status. Be aware that it can take an especially long time for this context menu to appear after you right-click. After a while, a cache status report appears that you can expand by clicking Show Details.
I have sometimes run into repeated crashes of the tiling processes when trying to build tiles of this map. If the reported number of tiles is not increasing when you view the status, or you get an error message about a crash, just take note of the scale level at which the tiles stopped generating, and move ahead to the next steps. It's not critical that you finish creating all the tiles for this Little Rock map; it's just for practice.
- While your tiles are being built (or afterward), take a moment to open Windows Explorer and navigate to the path: C:\arcgisserver\directories\arcgiscache\LittleRock\Little Rock, AR\_alllayers.
Take a look around. You'll see folders for each scale level of your cache. You might also see large files with the extension .bundle. A bundle file is Esri's way of storing a large number of tiles in one file. You can optionally store each tile as an individual image file using what ArcGIS Server calls the Exploded storage format, but when your cache starts containing thousands or millions of images it can be tedious for Windows to copy it around, assign permissions, or frankly do anything with it.
- When you are done creating tiles (or if you stopped because of a crash), open a web browser on your local computer and open the Services Directory. The URL will look like this: https://namegeog865.e-education.psu.edu/server/rest/services/
- If you don't see your LittleRock service in your list, open the ArcGIS Server Manager (https://namegeog865.e-education.psu.edu/server/manager) in your browser, and repeat the steps we performed in earlier lessons to make your service viewable by the public (Everyone).
- Zoom and pan around the map for a while, and note how quickly the tiles appear. Note that if your tile caching processes crashed, then you'll only be able to zoom in to the scale level at which the tiling stopped.
- When you are done creating and experimenting with tiles, stop your AWS Instance.
- Following the same pattern you used earlier in this lesson, open the AWS Management Console, and set your instance back to the t2.xlarge Instance Type.