Select to view content in your preferred language

How to export my map into PNG file in Python in Arcgis Pro

7768
7
Jump to solution
09-29-2020 07:10 PM
wwwu
by
Emerging Contributor

The counterpart of that in ArcMap is arcpy.mapping.exportToPNG(),

but i could not find the substitute in Arcpy.mp in arcgis pro

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

There are exportTo... methods bound to MapView—ArcGIS Pro | Documentation.  Either use the activeView property of an ArcGISProject or the defaultView property of a specific map.

aprx = arcpy.mp.ArcGISProject("CURRENT")
map = aprx.listMaps()[0]
map.defaultView.exportToPNG()

View solution in original post

7 Replies
DanPatterson
MVP Esteemed Contributor

From

Map—ArcGIS Pro | Documentation 

A map can also be accessed from a MapFrame object using the map property. Note: arcpy.mp does not provide access to map views within the application; it only provides access to MapFrames.

perhaps

MapFrame—ArcGIS Pro | Documentation  there is export to png there

Plus other salient bits of information beginning here

Migrating from arcpy.mapping to ArcGIS Pro—ArcGIS Pro | Documentation 


... sort of retired...
wwwu
by
Emerging Contributor

Thank you for your reply!

The documentation says that:

the method of ListElements on Layout Objects can get access to MapFrame

But when the scirpt below return a null list, do you know the reason?


pro = arcpy.mp.ArcGISProject("CURRENT")
mp = pro.listLayouts()

0 Kudos
DanPatterson
MVP Esteemed Contributor

See the code samples in

Layout—ArcGIS Pro | Documentation 

Of course, it will only work if you have one or more layouts


... sort of retired...
0 Kudos
wwwu
by
Emerging Contributor

But I don't want to export my layouts. I just want to export my map Object into a PNG file which comes from a .shp file. In the interface, I only need to click on the map icon and click on sharing, then I can export your map into a PNG file, which means map file can be directly exported into a png. But I couldn't find that function in Map class in the documentation.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

There are exportTo... methods bound to MapView—ArcGIS Pro | Documentation.  Either use the activeView property of an ArcGISProject or the defaultView property of a specific map.

aprx = arcpy.mp.ArcGISProject("CURRENT")
map = aprx.listMaps()[0]
map.defaultView.exportToPNG()
wwwu
by
Emerging Contributor

Thank you! This is just what I need!

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

Please mark a response as Correct to close out the question.

0 Kudos