Check GeoTIFF Placement in QGIS: Same Values, Different Locations

Lesson 6 · Data Science with DEB

A GeoTIFF can open normally, contain plausible NDVI values and still place them in a different location. In this lesson, we deliberately move the same raster 100 metres east, inspect it in QGIS and separate a display check from a geographic-accuracy claim.

Start with lesson five’s value and metadata checks. Here you will learn to compare footprints using the same display range. This is an article and code lesson; no new video accompanies it.

What the controlled example proves

We use the archived lesson-five NDVI raster: 72 rows × 63 columns, one float32 band, ten-metre pixels and EPSG:32643 (WGS 84 / UTM zone 43N). All 4,536 samples are valid in this file. The stored mean is approximately 0.467969.

The control changes only the affine transform’s easting origin from 576440 to 576540 metres. The northing origin, CRS, dimensions, values and validity masks stay the same. This is an intentionally incorrect metadata edit, not a reprojection, correction or new satellite observation. Do not use it as a way to repair a misaligned dataset.

Original bounds: (576440, 3418790, 577070, 3419510). Shifted bounds: (576540, 3418790, 577170, 3419510). At zero-based row 36, column 31, the pixel centre moves from (576755, 3419145) to (576855, 3419145). Its NDVI stays approximately 0.628600.

Same numbers on the same coordinate axes

Original and deliberately shifted NDVI rasters with identical coordinate axes and grayscale limits.
Both panels use fixed grayscale limits 0–1 and the same geographic axes. The dashed orange line marks the original western edge; the dotted green line marks the shifted edge. Negative NDVI values display black under this range but remain unchanged in the files. Select the figure to open it at full size.

Open both rasters in QGIS

  1. Run the complete Python example below in a writable lesson folder. Keep the original and generated control clearly named and separate from your research outputs.
  2. In QGIS, use Layer → Add Layer → Add Raster Layer. Add ndvi.tif and INTENTIONALLY_shifted_100m_east.tif. Put the shifted control above the original in the Layers panel.
  3. Confirm the project CRS is EPSG:32643 for this comparison. Double-click each layer and inspect its Information and Source properties. Compare the declared CRS, extent, dimensions and pixel size with the expected values above. Do not change the CRS label merely to make layers appear aligned.
  4. In each layer’s Symbology, select Singleband gray, Band 1, and the same fixed minimum 0 and maximum 1 with a min/max stretch. Avoid a separate automatic stretch based on each layer or a changing canvas extent. For checking negative values, repeat with a common range that includes them, such as −0.2 to 1.
  5. Zoom to the combined footprints, then leave the canvas extent unchanged. Toggle the shifted control off and on using its checkbox. The repeated pattern moves east. Do not zoom to each layer independently while comparing: recentering each image can conceal the displacement.
  6. Use Identify Features and inspect an appropriate pixel and layer. A click at the same map coordinate in two shifted rasters need not address the same row and column. Compare the stated pixel centres and expected geometry as well as the samples.

The QGIS visual check we performed

On 28 November 2026, QGIS 3.32 loaded the original and reconstructed shifted TIFFs. Both legends showed fixed 0–1 grayscale limits and the project showed EPSG:32643. Toggling the shifted layer at an unchanged canvas extent visibly displaced the repeated pattern east. The matching arrays, masks and exact 100-metre coordinate difference were independently checked by the Python script. The screenshots document the layer toggle; they are not a survey or an independent reference overlay.

QGIS displays the original NDVI alone while the shifted control is unchecked.
Original visible; shifted control unchecked. The original footprint ends farther west. Both layer legends retain the same 0–1 range. Open the screenshot at full size to inspect the interface.
The intentionally shifted NDVI control is checked above the original layer in QGIS.
Shifted control enabled above the original. The pattern moves east; a western strip of the original remains visible beneath it. The canvas has not been recentered.

Run the complete free example

The input is the same public numerical NDVI TIFF used in lesson five. The script downloads it only when absent, verifies its SHA-256, creates the separate shifted control, compares values and masks, and writes a figure and JSON results. Save the code as lesson06.py. Reruns overwrite its generated outputs; the original input is not overwritten.

python -m pip install numpy==2.5.1 rasterio==1.5.0 matplotlib
python lesson06.py
"""Lesson 6: controlled metadata error, not a correction or reprojection.
MIT License, Copyright 2026 Data Science with DEB.
Satellite input retains Copernicus source terms.
"""
from pathlib import Path
import hashlib
import json
import urllib.request
import numpy as np
import rasterio
from affine import Affine
from rasterio.plot import plotting_extent
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

folder = Path(__file__).resolve().parent
original = folder / 'ndvi.tif'
url = 'https://dibyendudeb.com/wp-content/uploads/2026/11/lesson-05-ndvi.tif'
expected_hash = '6763cde9ba86259c1b32e6c8188dc0fbe5f48af202eb1b2e7adf2d49f8694a94'
if not original.exists():
    urllib.request.urlretrieve(url, original)
assert hashlib.sha256(original.read_bytes()).hexdigest() == expected_hash

with rasterio.open(original) as src:
    values = src.read(1)
    valid = src.read_masks(1)
    profile = src.profile.copy()
    expected = src.transform
    original_bounds = list(src.bounds)
    centre = src.xy(36, 31)
    extent_a = plotting_extent(src)
    assert src.crs.to_epsg() == 32643
    assert values.shape == (72, 63)
    assert src.res == (10, 10)

shifted = folder / 'INTENTIONALLY_shifted_100m_east.tif'
# Shift map coordinates, not array indices. Do not use this to repair data.
profile['transform'] = Affine.translation(100, 0) * expected
with rasterio.open(shifted, 'w', **profile) as dst:
    dst.write(values, 1)
with rasterio.open(shifted) as src:
    assert np.array_equal(src.read(1), values)
    assert np.array_equal(src.read_masks(1), valid)
    shifted_centre = src.xy(36, 31)
    assert shifted_centre[0] - centre[0] == 100
    assert shifted_centre[1] == centre[1]
    assert src.transform != expected
    shifted_bounds = list(src.bounds)
    extent_b = plotting_extent(src)

result = dict(crs='EPSG:32643', shape=list(values.shape),
              original_bounds=original_bounds, shifted_bounds=shifted_bounds,
              original_centre=list(centre), shifted_centre=list(shifted_centre),
              pixel_row_col=[36, 31], pixel_value=float(values[36, 31]),
              mean=float(values.astype('float64').mean()),
              identical_values_and_masks=True, shift_east_metres=100,
              source_sha256=expected_hash,
              rasterio_version=rasterio.__version__, numpy_version=np.__version__)
(folder / 'placement_verification.json').write_text(json.dumps(result, indent=2))

fig, axes = plt.subplots(2, 1, figsize=(7, 10), constrained_layout=True)
for ax, extent, label in zip(axes, [extent_a, extent_b],
                           ['Original declared grid', 'Controlled error: 100 m east']):
    ax.imshow(np.ma.masked_where(valid == 0, values), extent=extent,
              cmap='gray', vmin=0, vmax=1, interpolation='nearest')
    ax.set_xlim(576390, 577220)
    ax.set_ylim(3418740, 3419560)
    ax.set_title(label)
    ax.set_xlabel('Easting (m), EPSG:32643')
    ax.set_ylabel('Northing (m)')
    ax.ticklabel_format(useOffset=False, style='plain')
    ax.set_xticks([576400, 576800, 577200])
    ax.set_yticks([3418800, 3419100, 3419500])
    ax.axvline(576440, color='#db6e24', ls='--', lw=1)
    ax.axvline(576540, color='#208c7d', ls=':', lw=1)
fig.suptitle('Same values and masks. Different map positions.\nFixed grayscale 0-1; negative values display black.')
fig.savefig(folder / 'placement_comparison.png', dpi=150)
plt.close(fig)
print(json.dumps(result, indent=2))

Executed on Windows with Python 3.14, Rasterio 1.5.0 and NumPy 2.5.1. All listed assertions passed. This combination emitted NumPy shape-setting deprecation warnings from raster reads; those warnings did not invalidate the checks. This small in-memory demonstration is not a large-raster processing design.

Consistency is not absolute position accuracy

Matching the archived source grid establishes consistency with that source. It does not establish that the source itself is correctly positioned on the ground. Both files could share a source error. For a real positional assessment, use independent reference data of suitable quality, date and resolution, account for CRS/datum transformations, and measure residual displacement at identifiable features. No such independent ground-reference overlay was performed here.

Likewise, a different colour palette or contrast stretch does not change stored NDVI. Exporting a rendered RGB image can create colour-channel samples instead of the original measurement. Keep numerical data and styled communication figures separate.

Before sharing your result

  1. Reopen the delivered TIFF and check its expected CRS, transform, bounds, dimensions, resolution, nodata and validity masks.
  2. Compare numerical values and selected pixel centres, not just the mean or a pleasing image.
  3. Use the same display range and unchanged canvas extent when comparing images.
  4. Record what reference was used, what was actually checked and what remains uncertain.
  5. Never distribute an intentionally shifted control as corrected data.

Test your understanding

Can an unchanged mean reveal a transform-only shift?
No. Every value can remain identical while their map locations change.

Why keep the same canvas extent during a toggle?
Independently recentering each raster can make the same pattern appear stationary even when the footprints differ.

Does a successful QGIS toggle validate crop condition or ground accuracy?
No. It illustrates a controlled spatial inconsistency. Those scientific claims require separate evidence.

Sources and reuse

References reviewed 28 November 2026: QGIS raster properties, symbology and Identify guidance and Rasterio georeferencing. The GUI check used the installed QGIS 3.32 interface; labels may differ in other versions.

Contains modified Copernicus Sentinel data 2024, processed through Google Earth Engine. The archived input derives from a Punjab sample dated 13 October 2024; crop identity and condition are unverified. Source data retain applicable Copernicus terms. The example script, original figure and display styles are released under the MIT License, copyright 2026 Data Science with DEB.

Return to the free learning path. Continue with lesson seven: missing dates and gaps in NDVI time series.

Leave a Comment