Use of GridIndexFeatures geoprocessing tool.

490
1
11-01-2012 07:07 AM
QuentinGore
New Contributor
Hello,

I am experimenting with data-driven pages in ARCGIS 10.0. To start with, I want to create a grid of polygons that can act as an index into a map book and the obvious way to do this is with the appropriate geoprocessing tool.

In order to prove the concept, I generated a shape file consisting of a single rectangular polygon. Then I ran the GridIndexFeatures tool manually from ArcMap, selecting page units, a map scale of 1:250000 and a page size slightly less than A4, I got an array of rectangles as I expected.

The next step was to replicate this in Java. My rough and ready first attempt was as follows:

private void generateGrid() throws IOException {
    double printableHeightInches = 11.0;
    double printableWidthInches = 7.5;
    
    GeoProcessor gp = new GeoProcessor();
    
    GridIndexFeatures gif = new GridIndexFeatures();
    
    // A shapefile containing a single geometry in the form of a rectangular selection
    gif.setInFeatures("rectangle.shp");
    // The output - should contain the grid of index features we want
    gif.setOutFeatureClass("grid.shp");

    gif.setUsePageUnit("true");
    gif.setScale(250000);
    gif.setPolygonWidth(printableWidthInches);
    gif.setPolygonHeight(printableHeightInches);
    gif.setIntersectFeature("true");
    
    IGeoProcessorResult result = gp.execute(gif, null);
  }

The trouble is, when I run this, the result is a single enormous rectangle. If I set the scale to 1 then the rectangle becomes more manageable, but what seems to be happening is that the width and height I've specified are being interpreted as map units instead of inches. I've tried to specify page units, as you can see, but I'm not sure if I've provided the correct parameter, and the API documentation isn't very forthcoming.

Any ideas?
0 Kudos
1 Reply
EricBader
Occasional Contributor III
Hi Quentin:

This sounds like a good question for the "ArcObjects - All Development Languages" forum:
http://forums.arcgis.com/forums/20-ArcObjects-All-Development-Languages

Have you also posted there?
0 Kudos