We create tile packages for field workers fairly frequently so they can have additional maps available to them when they go offline in the field. Typically this process has involved several different tools depending on the particular map or imagery that is needing to be tiled. Generally, I have found the ManageTileCache and ExportTileCache GP tools to be most reliable. So recently I started thinking about combining them along with the Python API so we could have one tool to use for publishing TPK's to our AGOL Org. Any feedback or suggestions would be greatly appreciated.
Basic outline of what the tool does:
- Make connection and get a token from your portal with whatever credentials are being used in Pro
- Take an input raster dataset
- Create a new folder for outputs in the same directory as the input dataset
- Allow user to name output dataset
- Run ManageTileCache tool to create a local tile cache ( by default the entire extent of the input dataset is used and LOD's are created based off of the input data source pixel information)
- Run ExportTileCache tool to create local tpk file
- Report file size info back via arcpy Messages
- Add tpk item to portal
- Attempt to publish the tpk as hosted tile layer
- Publishing a tpk item seemed to need the additional step of making a POST via the REST api to actually unpack and publish the tiles using '/updateTiles' contained in the tpk this is done using requests.post just simply using publish() with the python api tended to fail at going beyond creating the hosted tile layer.
- Uses urllib to get additional info about the hosted tile layer and LOD's being published.
This tool has been handy in certain situations for us and I hope it is for someone else too. Still I am always interested if someone has a better way of doing this.