Raster RowCount problem - different values

3093
5
11-28-2012 04:13 AM
RobertMEIER
Occasional Contributor
I am trying to get the row count of a raster, I have been able to do this easily enough, but the value does not match what is in the properties screen in ArcCatalog, see difference in the screen shots attached.

I have also used this code and have gotten the same, different, result from what ArcCatalog is showing.
        Geoprocessor gp = new Geoprocessor();
            GetRasterProperties getRP = new GetRasterProperties();
            getRP.in_raster = rlyr.Raster;
            getRP.property_type = "COLUMNCOUNT";
            gp.Execute(getRP, null);
            double cntcol = getRP.property;

            getRP.property_type = "ROWCOUNT";
            gp.Execute(getRP, null);
            double cntrow = getRP.property;


How is ArcCatalog getting it's rowcount value?

++++EDIT - I tried to get this with Python and got the same value as ArcCatalog -

>>> rowCount = arcpy.GetRasterProperties_management("s60193copy_01.cit", "ROWCOUNT")

>>> print rowCount

10037
++++EDIT
Any help or insight is appreciated!

-bert
0 Kudos
5 Replies
DuncanHornby
MVP Notable Contributor
Bert,

Not tried it but I guess your rlyr object is a RasterLayer object? If so this interface actually has a row count method called...wait for it... RowCount!

Duncan
0 Kudos
by Anonymous User
Not applicable
Original User: rwmeier

Duncan,

I know about that property, see the first screen shot, I show it there. The point of the post is not trying to find the row count, but asking why the row count from code, the RowCount property is different from the RowCount listed in the properties in ArcCatalog, see other screen shot.
0 Kudos
DuncanHornby
MVP Notable Contributor
Bert,

Not having the original dataset to interrogate makes it difficult to answer why the code version reports a different row count. I note that that the screen shot from ArcCatalog shows the cell size to be not symmetrical. This could be the source of the error? Maybe the algorithm behind the code version computes the row count based upon cell size and extent of dataset? This is the only thing I can think of. You can test this with a dataset that has a more typically symmetrical cell size.

Create a raster using the Create Raster Dataset tool so you know you are creating a grid that conforms to the esri standard and compare the different row count techniques.

Duncan
0 Kudos
by Anonymous User
Not applicable
Original User: rwmeier

Duncan,

The file is an Intergraph cit file. A scanned image. If you want to look at the file, I have attached a zip file with the cit file in it. A cit has mutiple files it uses, similar to a shape file.

-bert
0 Kudos
DuncanHornby
MVP Notable Contributor
Bert,

OK found the source of the difference. Go to ArcCatalog and work out the vertical extent distance (Extent top - extent bottom). This gives you a value of 10194.24176. Divide that by your Y length cell size and you get 10037. The code method you are using is assuming that you X and Y size are the same, but they are not in your case, thus if you divide the vertical extent difference by X length size you get 55996.

So it suggests that the code method assumes X and Y are the same length for a cell which is the normal case.

Duncan
0 Kudos