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:
- Open ArcMap
- Add County Boundary in the desired projection
- Create a GDB (i.e. \\R\Data\AA2009\AA2009.gdb)
- Create 3 Grid Index features at the same extent as the county bounds.
- 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
- L1_Poly = 2x2 (4 total)
- L2_Poly = 4x4 (16 total)
- L3_Poly = 8x8 (64 total)
Create Data Grid for Extent
- Select the GDB as the Output Location
- Name as L1_Poly
- ArcToolbox--> Cartography Tools-->Data Driven Pages-->Grid Index Features
- Select the county boundary as input feature
- Leave “Generate Polygon Grid” Checked if you want to only generate tiles for the county
- 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
Now that we have our Grid indexes for our Layer Lets Create the JPEGs.
- Add L1, L2, and L3 polygon feature classes (turn OFF)
- Add a Group Layer to put SID’s in (So you can turn them all on or off)
- Add all the image (SID’s) tiles you want into ArcMap (turn ON)
- In ArcMap, make sure the feature classes are named L1, L2 etc.
- Save Project
- Open Python Editor or, GeoprocessingàPython
- Run the script (see below) CreateWebCacheJpeg.py to create JPEGs of features
- Set variables
- out_loc - Output Location of JPEGs
- res – Resolution of the image to create
- Width- of the JPEG image to create in Inches
- inch_to_meters – this is the conversion factor to convert inches to map units (meters) in this case
- Copy the all code below and paste into python window
- Run code
- Set variables
- In ArcCatalog, Build Pyramids on all newly created JPGs.
- 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.)
- 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
- Repeat for L2 and L3 folders
Create Raster Catalogs
- 1) Create an empty GDB (i.e. R\Data\AA2009\AA2009.gdb)
- 2) Create 4 empty unmanaged raster catalogs
- Named L1, L2, L3, L4
- Set Coordinate System to WGS_1984_Web_Mercator_Auxiliary_Sphere
- Raster Management Unmanaged
- In ArcCatalog, Load JPGs into each of the above corresponding Raster Catalogs
- Open AE2009.gdb and right click on L1 raster catalog, select Load\Load Data, select all JPGs from L1 and click OK.
- Repeat for L2 and L3
- For L4, same as step 16, but Load all SID files
- Copy SID’s to webserver with cmd script (using cmd.exe)
- 1) Create an MXD with 4 groups corresponding to the raster catalogs and set their scales accordingly
- a) Add each Raster Catalog (L1, L2, L3, and L4) to the MXD and change Scale Range
- 2) Save ArcMap Project
- 3) Copy L1, L2, L3, SIDs folders and AE2009.GDB and MXD over to \\NTDMZGIS\Data (Only if you did not build it here)
- a) Need to create a new folder (i.e. AE2009) then copy all above into this folder
- 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.
- 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)
- d) Must add security permissions on NTDMZGIS on the directories and file Geodatabase for ntdmzgis/missdevwr user
- 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”
- i) ArcGIS Server: ntdmzgis
- ii) Service name: AE2009
- iii) Use an existing folder, Folder Name: ntdmzgis (root)
- iv) Click Next
- v) Click off KML, click Next
- vi) Click Finish
- 4) On NTDMZGIS, open up ArcGIS Server Manager and go to Services\Manage Services
- a) Edit the AE2009 Service
- b) Under the Parameters tab, change Output Directory to X:\arcgisserver\arcgisoutput
- 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.