Select to view content in your preferred language

ArcGIS Pro 2.5 - Python - MapView exportToPNG not correctly?

797
0
02-19-2020 06:29 AM
LukeCalladine
Occasional Contributor

I'm trying to export PNG's at a set scale based on the center point of a points file I have.

When I run my code I can see the map co-ordinates being panned around to each one along with the corresponding print command in the Python terminal - however, when it gets to the mv.exportToPng function - it prints black squares...

I can't for the life of me work out why if mv.panToExtent(thing[0].extent) moves my active map to the correct position why mv.exportToPng(...) won't print properly...

I would have used MapSeries if only the exportToPNG option would allow the writing of world files...

Anyway below is my code:

import arcpy, time
aprx = arcpy.mp.ArcGISProject('current')
mv = aprx.activeView
fc = r'D:\Image Detection\Image Detection ArcPro\Image Detection_Sentinel\Image Detection_Sentinel.gdb\Training_Data_Oman_Reliable_2015_Onwards'
count = 1
with arcpy.da.SearchCursor(fc, ['SHAPE@']) as cursor:
for thing in cursor:
mv.panToExtent(thing[0].extent)
print(thing[0].extent)
time.sleep(1)
mv.exportToPNG(os.path.join(r"D:\Image Detection\Image Detection ArcPro\Image Detection_Sentinel", "Output", f"Image_{count}.png"), width=4000, height=4000, resolution=300,world_file=True, color_mode="8-BIT_GRAYSCALE")
count += 1


Anyone got any ideas?

Luke

0 Kudos
0 Replies