I do have 3 grids made by Grids menu in data frame properties. I do need them to display in certain layout and also to behave accordingly to couple of rules (overlapping issues), so I can automate my production workflow. I figured that its not possible in the way I am trying to do now which is as per this Ask A Cartographer post entitled changing text characteristics of graticule labels.

So what are my alternatives? Is there a way to access grid labels in the existing mxd document and modify them according to my needs?

Probably its not possible with ArcPy, but maybe someone did it via ArcObjects (preferably in Python) and would like to share some experience?

I do not have any of the Production Mapping extensions, so I guess ArcObjects are my only option?


This is not much of an answer but it would not fit in the comment window;

You can do this with ArcObjects. I made a tool into which I enter parameters (extent, x and Y spacing) and it will create the grid in a existing polyline feature class. It's not too coplex to do this with ArcObjects but do create something like this does require a solid understanding of ArcObjects and VS.Net programming concepts. To do this dynamically for changing scales and to control labeling with ArcObjects would be a fairly complex add-in. (controlling dynamic labels programatically is difficult, at least I found it so) I only do a little bit of python mostly for geoprocessing for which it is primarily intended but I am pretty sure this cannot be done with python. Take this last statement with a grain of salt because I have not yet downloaded version 10.1 and I believe Python functionality has been extended in the new version. With ArcObjects however you can, among other things, control every aspect of the ArcMap framework which also allows you capture the extent of the layout extent and transform it real world coordinates and vice versa.

My add-in is a lot simpler then what you are looking for but it would be a good start. As I mentioned it creates the grid in a feature class based on the parameters you enter. It optionally stores coordinates as attributes and I then use maplex for labeling. Maplex has enough options to let me control where the grid labels should appear but then again I only do this in documents with a set extent.

If you'd like I can post the Add-in. If you want to improve it I will also post the source code.

  • Thanks Jakub, I'd like you to post the Add-in and source code :) I'll have a look and if needed will try to improve it. – Tomek Aug 28 '12 at 13:43
  • Thanks for Add-In. Works pretty well. My .Net skills are not that great, but I'll give it a shot. Thanks again. – Tomek Aug 30 '12 at 9:46
  • @Tomek - I have another Add-In up there for creating a polygon out of the current layout extent. Combining the 2 might be a good start - this would eliminate the need for the user parameters concerning extent. You could then calculate the default interval based on the page size. The last step would be listening to events when the extent changes and deleting the grid and re-generating it with a new one based on the new extent/page size. The creation of the grid itself is pretty quick so this could work. – Jakub Sisak GeoGraphics Aug 30 '12 at 13:06
  • Thanks Jakub, for now I am trying to get it done with arcobjects and Python. If this approach will fail, I'll ask you for the next plug-in. I'll send you my code if/when finished in Python, so you could see structure, as I think mix of arcpy and arcobjects, when needed, may be quite usefull. Thanks for help. – Tomek Sep 4 '12 at 5:43

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.