Something or someone has to tell the program a specific location is 30-40 rough.
This WGT Patent Application explains how they do it. Here's an image from that document showing how similar surface areas on an aerial photo of a hole could be outlined and designated as green, sand, fairway, rough, etc.
![](http://patentimages.storage.googleapis.com/US20080291216A1/US20080291216A1-20081127-D00012.png)
That outline is drawn by a human and creates a surface map. (So it won't be perfect.) The aerial photo is georeferenced so the point where the ball is on the surface map can be calculated. If the surface map has different colors for each surface type, the program can read the color of the pixel and look it up on a table of surface type colors. In other words, the ball is here on the surface map, the color on the map is blue, a blue color is water therefore, your ball is in the water.
For example, after painting in the colors the surface map could look like this.
![](http://i.imgur.com/jXfoJOJ.png)
Much more detail would be present to define fringe, brush, trees, 1st cuts of rough, 2nd cuts, etc.
Discrepancies like in the OP could be caused by differences in dates between the on-ground image and the aerial photo used to create the surface map. If the fairways were tighter when the aerial photo was taken vs wider when the cameraman took the fairway photo then it would account for the ball being shown on fairway grass, while the program says its 30-40.
Or the person drawing the outline had a mouse stutter. ;)
Just another part of the magic behind this game.