Select to view content in your preferred language

Focusing a MapFrame using a Polygon / Envelope

03-30-2020 11:49 AM
New Contributor III

We are creating a combined CoreHost / Python app that needs to place a variety of elements onto a Layout's MapFrame. This MapFrame already exists in a PAGX file, which will be imported and modified using ArcPy. Since this is a CoreHost app, we won't have access to the Layout namespace, so the actual modifications will have to occur in Python.

Thus far, the only properties I've found to modify the focus of a MapFrame (or its camera) deal with extents (x and y min and max) and camera heading. The problem here is that we have a geographically defined rectangle (with the same aspect ratio as the map frame) that we want to focus on. If this rectangle was perfectly oriented with true north, that would be fine - but that is almost never the case.

In the C# SDK, you can use the LayoutElementFactory to create a map frame using an Envelope, which is defined based on lower left and upper right coordinates, rather than min / max x and y. This is essentially how I need to be able to define the portion of my map I want the map frame to focus on.

Right now, however, it looks like I'll need to figure out the exact angle of rotation I'll need for the camera (based on the rectangular area of interest's orientation to north), as well as the exact scale. That would mean a very precise rotate and zoom-in set of operations, all done to focus the map frame on a certain rectangular area of the map.

Is there a simpler way to do this in ArcPy? Something akin to the C# SDK's use of an Envelope to create a specifically focused map frame?

Tags (3)
0 Kudos
0 Replies