Finding Golf Greens in Aerial Photos: From 15% to 89% Precision

Posted on November 22, 2026

Category: Technology

Tags: golf, computer-vision, deep-learning, semantic-segmentation, unet, pytorch, aerial-imagery, naip, remote-sensing, openstreetmap, geospatial, gis, datum-transformation, android, golf-gps

Views: 10

Finding Golf Greens in Aerial Photos: From 15% to 89% Precision

A golf GPS app answers one question: how far is it to the green? To answer it, the app needs the green's coordinates. For about 8,300 U.S. courses, OpenStreetMap volunteers have drawn the greens, and my app GPS4Golf reads them from there (the earlier post on the course API covers how). For more than 4,000 other courses in the same database, OpenStreetMap has only an outline of the property, or nothing at hole level at all. On those courses the app had nothing to measure to.

The United States publishes free aerial photos of the whole country. A green is easy to spot in them by eye: a smooth, bright patch with sand nearby at the end of a fairway. This post is about teaching a program to spot it, how the first attempt failed, what finally worked, and why the app still asks the golfer to make the last call.

A course with no hole map in GPS4Golf: white rings mark the greens found in aerial photos, and a prompt asks the golfer to tap a ring to set Hole 1's green.


The imagery: free, national, and coarser than advertised

The source is NAIP, the USDA's National Agriculture Imagery Program. It covers the lower 48 states every few years, it is in the public domain, and it has four bands: red, green, blue and near-infrared. Some states publish their own sharper imagery. North Carolina's is about 0.24 m per pixel, for example. But only NAIP covers every state, so the detector has to work on NAIP.

Two things about NAIP mattered from the start.


Attempt one: rules for colour and texture

The first detector was a set of hand-built rules. I tested it on Lakewood Golf Club, a course with no hole data in OpenStreetMap, where I had found the nine greens by hand to use as an answer key.

The first idea was vegetation index. NDVI compares near-infrared with red, and healthy grass is high. I expected greens to be the most vivid grass on the course. They were the opposite. A green is mown to about 3 mm, so it has little leaf mass, and its NDVI was lower than its surroundings (0.176 against 0.197). NDVI separated only 5 of the 9 greens.

Texture worked much better. A green is extremely uniform. The local standard deviation was 0.010 on greens and 0.096 around them, and that separated all 9 of 9. So the pixel question, smooth turf or not, was solved.

The object question was not. Fairways are also smooth, mown turf. A green that touches its apron merges with the fairway into one blob, and the blob's centre lands tens of metres from the pin. The results:

Measure Result
Smooth-turf pixels told apart from rough and trees 9 of 9 greens
Greens found, with 40 candidates proposed 6 of 9
Precision 15%
Centre error, on the greens it found 4.7 m on average

At 15% precision, a person has to reject 34 of 40 candidates. At that point it is faster to look at the photo and tap the greens yourself.

I tried three fixes, and none of them worked.

The conclusion I wrote down at the time was: with pixel colour and texture rules, greens cannot be found in NAIP without a seed. That conclusion was right about the rules and wrong about the imagery.


Attempt two: let OpenStreetMap be the teacher

The rules failed because "green" is not a property of a pixel. A green is the smooth patch at the end of a hole, ringed by bunkers and apron, with a particular size and shape. That kind of context is what a convolutional network learns well. Convolutional networks need labelled examples, and I already had thousands of them: every course where OpenStreetMap volunteers had drawn the greens.

The training set was built like this.

  1. Pick courses where OpenStreetMap has full hole data.
  2. Download the NAIP image of each course, all four bands.
  3. Draw the mapped greens onto a mask aligned with the image.
  4. Train a U-Net, an encoder–decoder network that labels every pixel, to predict the mask from the image.

The network predicts three things at once: greens, tees, and the corridor of each hole. Only the greens matter for this post.

The split is by region, not by hole. My earlier oracle test taught me this. If the test holes come from the same courses and the same photo flights as the training holes, the score is inflated. So two whole regions were held out and never used for training: the Carolinas, where my earlier hand-checked courses are, and the desert Southwest. The Southwest has irrigated turf surrounded by bare ground, which is the furthest from most of the training data.

I trained two models with the same training budget. One saw 240 training courses and the other saw 1,217. On 30 held-out courses per region:

Measure Carolinas, 240 → 1,217 Southwest, 240 → 1,217
Green recall 92.8% → 94.4% 90.5% → 91.4%
Green precision 87.3% → 89.1% 85.8% → 88.5%
Median centre error 1.2 m → 1.1 m 1.0 m → 1.0 m
Greens within 5 m of the mapped centre 91.0% → 92.0% 88.4% → 89.9%

Precision went from 15% to about 89%. The centre error went from 4.7 m to about 1 m, less than two NAIP pixels, and better than my old rules did even on the sharper North Carolina winter imagery (2.1 to 2.4 m). The validation pixel F1 score was slightly lower for the larger model (0.653 to 0.644), but it was better on every test-region green measure that matters to the app. A pixel score does not tell you how many greens you found.

Tees were a different story. Tee recall was 51% to 63%, and only about a third of tees were correctly paired with their green. Tee boxes are small, often shaded, and look like any other mown rectangle. That result decided how the app uses the output, as the last section explains.


The half-metre nobody mentions: datums

For the batch run I switched to reading NAIP straight from Microsoft's Planetary Computer, which serves the original files instead of a rendered mosaic. The Southwest median centre error jumped from 1.0 m to 1.7 m. The network had not changed.

The cause was the coordinate datum. The original files are in NAD83, the North American datum. The app, OpenStreetMap and every phone GPS use WGS84. By default, the common projection library treats NAD83 and WGS84 as identical. They are not: the two datums have drifted apart by a metre or more over the decades as the continent moves. Once the conversion used the actual photo date, the Southwest error dropped to 0.8 m, the best of all the runs.

A metre does not matter to a golfer. But it ate most of the accuracy I had just gained, and the only sign of it was a test-set number that got worse for no visible reason.


From detections to courses the app can open

The batch run covered 4,316 courses with no usable hole data, at 4.3 seconds per course once downloading and inference ran in parallel. It produced 52,120 green candidates. Candidates that sat on a green OpenStreetMap already had were dropped.

The candidates for a course are useful only if they plausibly are that course's greens. So every course gets a detection grade. If the number of greens (mapped plus detected) is close to a standard course size, 9, 18, 27 or 36 holes, the course is graded D1. Otherwise it is D2 and is flagged for review. On 90 held-out courses, D1 courses had 91% green precision and 92% recall. 2,950 of the 4,316 courses came out D1.

Courses that are not in the database at all went through the same pipeline: 1,892 more, of which 1,642 graded D1. Together, the app now opens about 13,000 U.S. courses. Before, it opened about 8,300.


Why the golfer still taps the green

The model gives a set of greens, not holes. To turn greens into Hole 1, Hole 2 and so on, the app needs the routing, and the evidence for that is weak.

Numbering a course from those guesses would put a wrong "Hole 7" on screen about one time in four. That is worse than showing no number. A golfer who trusts a wrong yardage hits the wrong club.

So the app does not guess. On a D1 course, the detected greens appear as white rings on the map. When you reach a hole, you tap the ring on the green you are playing to and pick the hole number and par. From then on, the yardage is live, and the course keeps the green for next time. That is one tap per hole, once per course. The model does what it is good at, finding greens to within a metre. The golfer does what the photos cannot, knowing which green is next.

After the golfer taps a ring, the green is set for Hole 1 and the screen shows 152 yards to it from the fairway.


What I took away

The app is GPS4Golf on Google Play. Courses without a hole map arrived in version 1.1.0.


References


Disclaimer: This blog post was created with assistance from Claude, an AI developed by Anthropic, under my direct supervision and guidance to ensure accuracy and alignment with my vision for the content.