Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Running inference and predicting continuous values over time

You trained a model on the previous page. This page applies it across full rasters, first the training-year scene to check it against known values, then a different year entirely, to see whether it generalizes across time.


1. Motivation

A model that only works on the exact tiles it was trained on is not very useful. Running wall-to-wall inference, and specifically testing it on imagery from a year it never saw, is what tells you whether the model actually learned a generalizable mapping from imagery to NDVI, rather than memorizing its specific training scene.


2. Core idea

geoai.predict_raster() runs the same kind of tiled inference you have seen in earlier lessons, sliding a window across a full raster and stitching results together, here using overlap with Gaussian-weighted blending to avoid visible seams in a continuous-valued output, where any hard edge between tiles would be immediately obvious.


3. Workflow

A. Run inference on the training area

Running inference on the 2022 training raster first, even though the model already saw this imagery during training, lets you evaluate predictions against the known 2022 NDVI ground truth on the next page, a useful check before trusting the model on genuinely new imagery.

B. Overlap, blending, and clipping

overlap=64 means adjacent tiles share 64 pixels; predict_raster() blends predictions in these shared regions using Gaussian weighting, which favors each tile’s more reliable center over its edges, smoothing out the transition rather than creating a visible seam at every tile boundary. clip_range=(-1.0, 1.0) enforces NDVI’s valid physical range on the output, the inference-time counterpart to the target_min/target_max filtering applied during tile creation two pages ago.

C. Predict on new imagery

This is the same function call, applied to test_raster, the 2023 Landsat scene the model never saw during training. If the model has learned a genuine relationship between spectral bands and NDVI, rather than memorizing specifics of the 2022 scene, it should produce plausible NDVI predictions for 2023 as well.

D. Visualize the temporal prediction

Displaying the 2023 input imagery alongside its predicted NDVI map lets you visually check whether the predicted vegetation patterns make sense relative to what the imagery actually shows, greener areas predicted as higher NDVI, built-up or bare areas predicted as lower, before treating the result as usable.


4. Python reactivation

Nothing new syntactically here; this page reuses the same function-call pattern from earlier pages, applied first to familiar imagery and then to new imagery, with input_raster as essentially the only thing that changes between steps A and C.


5. Common pitfalls


6. Mini task

The 2023 prediction map shows a cluster of pixels with unusually high NDVI values in an area that appears, in the input imagery, to be a parking lot. List two possible explanations, and how you might investigate which applies.

Sample solution

One possibility is a genuine model error: the model may have learned spurious associations that do not hold for this specific location or year, especially plausible if this area looked different (perhaps vegetated) in the 2022 training imagery. Another possibility is that the input imagery itself has an issue at that location, cloud contamination, a processing artifact, or misregistration, causing the model to receive misleading input. To investigate, you would compare the 2022 and 2023 imagery at that specific location directly, and check whether the anomaly is isolated to a few pixels (more consistent with noise or a local artifact) or covers a broader, spatially coherent area (more consistent with a genuine, if surprising, model behavior worth understanding further).


7. Key takeaways