Saturday 26 June 2021

How to export Data Driven Pages into PNG with high Resolution

- 0 comments

Why do we need this? 

This process is needed mostly when the export is needed as a image file not as vector. And the default option need to be exported one by one. However ESRI offers an option in official documentation about this process.

How to do it step-by-step?


Step 1:
Copy these lines of python code and paste it into a text editor (Notepad, notepad++, sublime...etc).

mxd = arcpy.mapping.MapDocument("CURRENT")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
mxd.dataDrivenPages.currentPageID = pageNum
arcpy.mapping.ExportToPNG(mxd, r"C:\Temp\ParcelAtlas_Page" + str(pageNum) + ".png")
del mxd

These codes are downloaded into official documentation of exporting data driven pages. Search in google "Export data driven pages" or click here.

Step 2:

Modify the code using custom resolution and modify path+name.

mxd = arcpy.mapping.MapDocument("CURRENT")
for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1):
mxd.dataDrivenPages.currentPageID = pageNum
arcpy.mapping.ExportToPNG(mxd, r"C:\your_path\your_name" + str(pageNum) + ".png",resolution=400)
del mxd

Step 3:

Open python window into your arcmap project, paste this code and press enter. All your sheets will be exported into your working folder.




Extra Steps!

Export data driven pages with PageName using python scripts.


Step 4:
Open attribute table of the data driven layer, copy all records and paste into an excel sheets. Remove all unnecessary fields except (the field that you have used as Sort field and the field that you have used as a name field in data driven setup). My case, FID and ID which is the building number that im using as field name in data driven pages setup and FID as the sort field. 





Step 5:

Sort these two field using FID (be sure this field is marked as number), copy the ID field and paste as transposed in the same sheet.

Step 6:

Copy the transposed records and paste into Notepad++, replace all Tabs with Quote-Comma-Quote and replace all Slashes with underscore
tabs => ','
/ => _
Create a valid python list with name pageID:

pageID = ['9','11','8','7b','7a','6_4','6_3','6_2','6_1','12_1','12_2','10_1','10_2','10_3','5','4','3','2','1']


Step 7:
Modify the final script, copy all script and paste into python window:

pageID = ['9','11','8','7b','7a','6_4','6_3','6_2','6_1','12_1','12_2','10_1','10_2','10_3','5','4','3','2','1'] mxd = arcpy.mapping.MapDocument("CURRENT") for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = pageNum arcpy.mapping.ExportToPNG(mxd, r"C:\Users\User\Desktop\test\png\{}".format(pageID[pageNum])+ ".png"),resolution=300) del mxd


Youtube Video:

[Continue reading...]
 
Copyright © . Geospatial Guy - Posts · Comments
Theme Template by BTDesigner · Powered by Blogger