2

We use arcpy.mapping for print tasks.

The slowest part in workflow is arcpy.mapping function ConvertWebMapToMapDocument; it takes 10-12 seconds each time, doesn't matter if map is big or not. We use ConvertWebMapToMapDocument(mapJson, templateMxd) form. templateMxd is empty A3 document with empty data frame and north arrow.

Function ExportToPNG takes only 2 seconds while ConvertWebMapToMapDocument eats most of the total printing time.

What can be tips to improve performance here?

Edit: ------------------
Looks it's not possible to solve it for myself as ConvertWebMapToMapDocument implementation spends a lot of time in unnecessary web requests.
Simplest example:


import time
import arcpy

templateMxd = 'C:\\Program Files\\ArcGIS\\Server\\Templates\\ExportWebMapTemplates\\A3 Portrait.mxd'
mapJSON = '{"layoutOptions": {"titleText": "Simple WebMap JSON example"},"operationalLayers": [{"url": "http://maps1.arcgisonline.com/ArcGIS/rest/services/USA_Federal_Lands/MapServer","visibility": true}],"exportOptions": {"outputSize": [1500,1500]},"mapOptions": {"extent": {"xmin": -13077000,"ymin": 4031000,"xmax": -13023000,"ymax": 4053000}},"version": "1.4"}'

timer = time.time()
aTuple = arcpy.mapping.ConvertWebMapToMapDocument(mapJSON, templateMxd)
print('ConvertWebMapToMapDocument took %.2f s' % (time.time() - timer))

Output:

ConvertWebMapToMapDocument took 2.10 s

Now where all this time went? I used Fidler2 to track web requests and got following:

http://maps1.arcgisonline.com/ArcGIS/rest/info?f=json
http://maps1.arcgisonline.com/ArcGIS/rest/services/USA_Federal_Lands/MapServer?f=json
http://maps1.arcgisonline.com/ArcGIS/rest/services/USA_Federal_Lands/MapServer/layers?&f=json
http://maps1.arcgisonline.com/ArcGIS/rest/services/USA_Federal_Lands/MapServer/legend?&f=json
http://maps1.arcgisonline.com/ArcGIS/rest/info?f=json
http://maps1.arcgisonline.com/ArcGIS/rest/info?f=json
http://maps1.arcgisonline.com/ArcGIS/rest/services/USA_Federal_Lands/MapServer?f=json
http://maps1.arcgisonline.com/ArcGIS/rest/services/USA_Federal_Lands/MapServer/layers?&f=json
http://maps1.arcgisonline.com/ArcGIS/rest/info?f=json
http://maps1.arcgisonline.com/ArcGIS/rest/info?f=json
http://maps1.arcgisonline.com/ArcGIS/rest/services/USA_Federal_Lands/MapServer?f=json
http://maps1.arcgisonline.com/ArcGIS/rest/services/USA_Federal_Lands/MapServer/layers?&f=json

Aggregate Session duration: 00:00:01.687

Only first 4 requests are actually needed other requests are duplicates. For these 4 requests

Aggregate Session duration:    00:00:00.683

Such optimization would save 1 second of 2.10 s spent in ConvertWebMapToMapDocument function.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.