# Alternative to ArcGIS Tiled Map Service

Blog Post created by vanhornsky on Feb 19, 2015

Creating Server-side Tiling 10.1

Problem A: MrSID tiled imagery is only realistically viewable at scales of < 1:50,000.

Problem B: In order to optimize viewing of imagery for the web it is best to tile imagery according to pre-set scales (e.g. the Google Maps/ESRI/Virtual Earth tiling scheme) - this is a rather time and space consuming chore. It also mandates that the imagery layer be considered an ArcGISTiledMapService for the intents and purposes of ESRI web-APIs

All run in ArcGIS 10.2.2

Solution: Server-side tiling.  In order to optimize NAIP imagery viewing:

# Steps:

1. Open ArcMap
2. Add County Boundary in the desired projection
3. Create a GDB (i.e. \\R\Data\AA2009\AA2009.gdb)
4. Create 3 Grid Index features at the same extent as the county bounds.
1. This can be as big or as small as you want and you can add more detailed layers in this case we are going to make a total of four layers

For Example:

• L1_Poly = 2x2  (4 total)
• L2_Poly = 4x4 (16 total)
• L3_Poly = 8x8 (64 total)

## Create Data Grid for Extent

1. Select the GDB as the Output Location
2. Name as L1_Poly
3. ArcToolbox--> Cartography Tools-->Data Driven Pages-->Grid Index Features
1. Select the county boundary as input feature
2. Leave “Generate Polygon Grid” Checked if you want to only generate tiles for the county
3. Calculate the size of the grid to be made by changing the units to meters and enter 1 as the width and height. This will give the number of rows and columns in meters effectively the size of the area we are working with.

Now take the Number of Rows divided by how many rows you want

Basically this is saying the minimum size to cover this area is a grid of 2 rows and 2 columns equals 4 tiles total and each grid being 111,637m height x 104,297m width

Note: width is columns and height is rows

Normally I round up to a convenient number like 112,000m x 105,000m

e)  Repeat this for L2 and L3

## Create JPEGs

Now that we have our Grid indexes for our Layer Lets Create the JPEGs.

1. Add L1, L2, and L3 polygon feature classes (turn OFF)
2. Add a Group Layer to put SID’s in (So you can turn them all on or off)
3. Add all the image (SID’s) tiles you want into ArcMap (turn ON)
4. In ArcMap, make sure the feature classes are named L1, L2 etc.
5. Save Project
6. Open Python Editor or, GeoprocessingàPython
7. Run the script (see below) CreateWebCacheJpeg.py to create JPEGs of features
1. Set variables
1. out_loc - Output Location of JPEGs
2. res – Resolution of the image to create
3. Width-  of the JPEG image to create in Inches
4. inch_to_meters – this is the conversion factor to convert inches to map units (meters) in this case
2. Copy the all code below and paste into python window
3. Run code

## Create Pyramids

1. In ArcCatalog, Build Pyramids on all newly created JPGs.
1. In the L2 and L3 folders, in Windows Explorer, look for any JPGs that do not contain any imagery and delete those JPGs and corresponding files (i.e. xml, rrd, jpw, etc.)
2. Open L1 folder and select all JPGs and right click and select Build Pyramids or,   ArcToolbox--->Data management ToolsàRaster-->Raster Properties-->Batch build Pyramids
3. Repeat for L2 and L3 folders

## Create Raster Catalogs

1. 1) Create an empty GDB (i.e. R\Data\AA2009\AA2009.gdb)
2. 2) Create 4 empty unmanaged raster catalogs
1. Named L1, L2, L3, L4
2. Set Coordinate System to WGS_1984_Web_Mercator_Auxiliary_Sphere
3. Raster Management Unmanaged
3. In ArcCatalog, Load JPGs into each of the above corresponding Raster Catalogs
1. Open AE2009.gdb and right click on L1 raster catalog, select Load\Load Data, select all JPGs from L1 and click OK.
2. Repeat for L2 and L3
4. For L4, same as step 16, but Load all SID files
1. Copy SID’s to webserver with cmd script (using cmd.exe)
1. 1) Create an MXD with 4 groups corresponding to the raster catalogs and set their scales accordingly
1. a) Add each Raster Catalog (L1, L2, L3, and L4) to the MXD and change Scale Range
 Layer Name Out Beyond In Beyond L1 None 1:250,000 L2 1:249,999 1:85,000 L3 1:84,999 1:35,000 L4 1:34,999 None
1. 2)    Save ArcMap Project
2. 3) Copy L1, L2, L3, SIDs folders and AE2009.GDB and MXD over to \\NTDMZGIS\Data (Only if you did not build it here)
1. a) Need to create a new folder (i.e. AE2009) then copy all above into this folder
2. b) On NTGIS, open ArcCatalog and Load all JPGs and SID files into corresponding Raster Catalog, making sure the path is to \\NTDMZGIS\Data\AE2009\L1  etc.
3. c) Open the MXD (on \\NTDMZGIS\Data\AE2009) on NTGIS and repoint the paths of L1, L2, L3, and L4 to \\NTDMZGIS\Data\AE2009\L1 and save MXD.  Make sure all SID files have a Spatial Reference (NAD_1983_StatePlane_Arizona_Central_FIPS_0202_Feet_Intl) and make sure the Data Frame Properties Coordinate System is set to (WGS_1984_Web_Mercator_Auxiliary_Sphere)
4. d) Must add security permissions on NTDMZGIS on the directories and file Geodatabase for ntdmzgis/missdevwr user
5. e) Open the Map Service Publishing toolbar, and click the Analyze Map to check for any errors, if good, then click on the Save Map Service Definition, and it will save a MSD file.  Now click on the Publish To ArcGIS Sever.

Note: This error is normal “Layer's data source is referenced via a UNC path”

1. i) ArcGIS Server: ntdmzgis
2. ii) Service name: AE2009
3. iii) Use an existing folder, Folder Name:  ntdmzgis (root)
4. iv) Click Next
• v) Click off KML, click Next
• vi) Click Finish
1. 4) On NTDMZGIS, open up ArcGIS Server Manager and go to Services\Manage Services
1. a) Edit the AE2009 Service
2. b) Under the Parameters tab, change Output Directory to X:\arcgisserver\arcgisoutput
3. c) Click Save and Restart

End result - a dynamic map service that should draw equally fast at all scales and will allow for custom scales.

NOTE: Must set this layer to an ArcGISDynamicMapService to consume it.