2

Our GIS users have been using graphics to mark things in their map documents. By graphics, I mean circles, rectangles, lines, text, etc. that can be drawn into data view by using the Draw toolbar. We have a spatial reference (sr) change of all our geodata upcoming. Using Python, I want to crawl through hundreds of MXDs and replace all layer's data sources to point to the feature classes in the new sr. Also the script will set the sr of the data frames to the new sr.

But what about the graphics?

After the sr change, the graphics must still lie correctly relative to the features in the new sr. I didn't find a way to directly access and manipulate graphics with arcpy. As a workaround, I tried creating a custom transformation "sr old to sr new" and added it to the dataframe, assuming that the graphics have been drawn in the old sr and should therefore be transformed to the new sr. Unfortunately, this had no effect on the graphics. After many test runs of the script, the graphics lie displaced relative to the features in the new sr.

How can I transform the graphics to the new sr, so that they will maintain their correct position relative to the features?

Is there a way to directly access and manipulate graphics with ArcPy?

I am using ArcGIS Desktop 10.2.1.

  • 1
    You can convert most graphics to features resources.arcgis.com/en/help/main/10.1/index.html#//… However, I am not certain if this is possible through python :( – GISKid May 23 '14 at 15:39
  • I am pretty sure this can be done through ArcObjects, though I don't have any examples. Probably start with IGraphicsContainer and IGraphicElement, followed by ITransform2D and updating the elements' and data frame's spatial references. – blah238 May 24 '14 at 3:49
1

It sounds as if you may want to use the Convert Graphics to Features command first and work from there.

http://resources.arcgis.com/en/help/main/10.1/index.html#//00s900000008000000

Changing the spatial reference will not affect things that are drawn on the map.


@GISKid makes a great point about python probably not being able to accomplish this task. The python accessible arcpy.mapping.ListLayoutElements(mxd, 'GRAPHIC_ELEMENT') works with graphics added in the layout view but does not appear to allow you to convert the graphics to features. The probably not python accessible Convert Graphics to Feature command works on graphics added in data view.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.