Understanding Map Projections, Coordinate Systems, and Tile Generation
The article explains why flat maps require projections, compares conformal, equal‑area and equidistant methods, describes the WGS84 datum and the GCJ‑02 “Mars” offset, outlines modern Web Mercator tiling standards, and shows how Python libraries like mercantile, pygrib, xarray, GDAL and rasterio can be used to read gridded data and produce map tiles.
Why Projections Are Needed
Because the Earth is a sphere, representing its surface on a flat sheet requires a projection that maps spherical coordinates to a plane. Early maps were hand‑drawn on paper, but precise or large‑scale maps cannot ignore the planet’s curvature.
What a Projection Is
A projection is essentially a shadow of the globe onto a plane, created by choosing a light source (point, line or area) and its position (center, pole, etc.). It reduces three‑dimensional geography to two dimensions, inevitably sacrificing some metric property.
There is no perfect projection; preserving angles distorts area and distance, and vice‑versa. EPSG lists 5,822 coordinate reference systems, classified by the property they preserve, such as conformal, equal‑area, or equidistant.
Conformal Projections
Conformal (shape‑preserving) projections keep angles unchanged. The most common is the Mercator projection, which greatly distorts area toward the poles—Russia and Canada appear larger than they are, and the projection cannot cover the poles.
A compromise is the Lambert conformal conic projection, used for Chinese weather maps, which reduces polar distortion while still preserving local shapes.
Equal‑Area Projections
These sacrifice shape to keep area accurate; examples include the Mollweide projection.
Equidistant Projections
Equidistant projections preserve distances from one or two special points. The equidistant cylindrical projection (often the default in mapping software) keeps distances along the equator, while the equidistant conic projection preserves distances between the poles.
Geodetic Datums: WGS84 and GCJ‑02
WGS84 (World Geodetic System 1984) is the globally accepted datum, approximating the Earth with an ellipsoid. Other historic datums include the Soviet Krasovsky ellipsoid and China’s Beijing 54 and Xian 80.
GCJ‑02, colloquially called the “Mars coordinate system,” is a government‑mandated offset applied to WGS84 in China for security reasons, typically shifting coordinates by up to 700 m. It is the basis for maps from services such as Gaode (Amap).
Rise of Modern Map Tile Technology
Before tiles, maps were delivered as a single large image or rendered on demand, both of which strained bandwidth and compute resources. Google Maps pioneered tiled maps by cutting the world map into hierarchical 256 × 256 px squares (quad‑tree), loading only the needed tiles.
This approach became the industry standard; Bing, OpenStreetMap, Apple, Baidu, Gaode, and Tianditu all use the same tiled Web Mercator scheme.
Generating Map Tiles with Python
Grid Data I/O Tools
Gridded (raster) data formats such as GRIB, NetCDF, HDF, and GeoTIFF store meteorological or satellite observations as 2‑D numeric matrices. Python libraries for reading them include pygrib, netCDF4, and xarray.
Tile Mapper with mercantile
The mercantile package converts latitude/longitude and zoom level to tile row/column indices and vice‑versa, enabling placement of grid values into the correct Web Mercator tiles and naming them as z/y/x.png.
import mercantile
# Get tile for a coordinate at zoom 4
tile = mercantile.tile(116.402544, 39.912943, zoom=4)
print(tile) # Tile(x=13, y=6, z=4)
# Get bounding box of that tile
bbox = mercantile.bounds(tile)
print(bbox) # LngLatBbox(west=112.5, south=21.94..., east=135.0, north=40.98...)Projection Conversion with GDAL / rasterio
After reading the data, it must be re‑projected from its native geographic CRS to Web Mercator. GDAL provides a powerful command‑line interface and a Python API, while rasterio offers a more Pythonic wrapper for simpler tasks.
References
[1] earth: https://earth.nullschool.net/
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
