Is it possible to export a Map Frame to JPEG with a world file (JPW) that respects its extent?
Using ArcGIS Pro 2.0.1 (and I think the behaviour at 1.4.1 was the same) I have noticed something that seems odd. Using the GUI it is possible to have a Map active and Share | Export Map to produce a JPEG (
*.jpg) file with an accompanying world file (
*.jpw) that appears to be what is seen in that Map at the time it is exported.
To see this:
- Create a new project called TestProject in C:\Temp using Map.aptx as a template.
- Run the ArcPy code below to write a test feature class (fishnet) into its file geodatabase.
import arcpy testFC = r"C:\Temp\TestProject\TestProject.gdb\TestFC" if arcpy.Exists(testFC): arcpy.Delete_management(testFC) arcpy.management.CreateFishnet(testFC, "152 -25", "152 -24", 0.1, 0.1, 10, 10, None, "NO_LABELS", "DEFAULT", "POLYGON") sr = arcpy.SpatialReference("Geocentric Datum of Australia 1994") arcpy.management.DefineProjection(testFC,sr)
- In ArcGIS Pro add the feature class to the project's only Map
- Insert a Layout into that project (I used A4 Portrait)
- On that Layout insert a Map Frame using the Map (not at the Default scale)
- Make the Map active, and use Share | Export Map to
C:\Temp\Map.jpgand tick the Create world file box. This makes
The Map looks like this in ArcGIS Pro:
The Layout looks like this in ArcGIS Pro:
When I use ArcMap 10.5 to check whether the world file is working I need to edit the coordinate system (Geocentric Datum of Australia 1994) onto Map.jpg using the Catalog window first, but then I can display it against the OpenStreetMap basemap to see:
which does not look great but it was quick to make and looks like it is the area I am after.
In contrast, when I try to do the same thing using ArcPy for ArcGIS Pro there is not a method to export from a map object but there is one to do it from a map frame:
import arcpy aprx = arcpy.mp.ArcGISProject(r"C:\Temp\TestProject\TestProject.aprx") lyt = aprx.listLayouts("Layout") mf = lyt.listElements("MapFrame_Element", "Map Frame") mf.exportToJPEG(r"C:\Temp\Map2.jpg",96,True)
This took 10-20 mins to complete and produced this when I viewed it in ArcMap and gave it the same coordinate system (Geocentric Datum of Australia 1994):
I have no idea why it produces an image over such a large extent, and I am assuming that it is doing that which causes it to take so long to export.
The behaviour is the same with ArcGIS Pro 2.1.2 when trying to exportToTiff and create a GeoTIFF.