← All articles

By ·

Why Your Web Map Gets Distance and Area Wrong: Web Mercator Errors and Which CRS to Use

Web Mercator (EPSG:3857) inflates distance by 1/cos(latitude). In Calgary a 3-mile buffer drawn in it covers 40% of the intended area. Which CRS to use instead.

Web Mercator (EPSG:3857) is the projection behind almost every web map, and it stretches every distance by 1 divided by the cosine of the latitude. A 3-mile buffer drawn in it covers 81% of the intended area in Miami, 52% in Toronto and 40% in Calgary. In downtown Calgary that "3-mile" buffer held 135,388 residents. The true 3-mile circle held 225,880.

This article shows how large the error is at different latitudes, how it creeps into real analysis, and which coordinate reference system (CRS) or method to use instead, with the commands to do it in PostGIS, Python, QGIS and ArcGIS.

What is Web Mercator and why is it everywhere?

Web Mercator, registered as EPSG:3857 and sometimes called Pseudo-Mercator, is the projection used by the standard tile schemes of OpenStreetMap, Google Maps, Bing Maps, Mapbox and ArcGIS basemaps. It became the default because:

The cost is size. Mercator projections enlarge everything away from the equator, by the same factor in every direction at a given point:

scale factor k = 1 / cos(latitude)

Lengths are stretched by k and areas by k². That is why Greenland looks as big as Africa on a web map when Africa is about 14 times larger. You can drag Greenland onto Africa yourself on the True Size Map.

None of this is a problem for display. It becomes a problem when the coordinates of a Web Mercator layer are used for measurement: a buffer, a length, an area, a nearest-distance join or a density per square kilometre. Esri's own support notes call the Web Mercator coordinate system unsuitable for calculating distance and area, and QGIS developers have said the same when users reported "wrong" areas in EPSG:3857 layers.

How large is the error at different latitudes?

I calculated the Web Mercator scale factor with pyproj, then drew a 3-mile (4,828 m) buffer in EPSG:3857 around each city and measured its real area on the WGS 84 ellipsoid.

CityLatitudeLengths stretched byAreas inflated byReal radius of a "3-mile" EPSG:3857 bufferReal area as share of intended
Miami25.8°N1.1101.23×2.70 miles81%
Dallas32.8°N1.1891.42×2.52 miles71%
Islamabad33.7°N1.2021.44×2.50 miles69%
Denver39.7°N1.3001.69×2.31 miles59%
Toronto43.7°N1.3821.91×2.17 miles52%
Seattle47.6°N1.4832.20×2.03 miles45%
Calgary51.0°N1.5912.53×1.89 miles40%
Edmonton53.6°N1.6832.83×1.79 miles35%
Anchorage61.2°N2.0774.31×1.45 miles23%

Read the table both ways:

Across the populated parts of the US and Canada, the error runs from about 11% in length (23% in area) in Miami to 68% in length (183% in area) in Edmonton. There is no latitude in North America where it is small enough to ignore.

Left: bar chart of the real area covered by a 3-mile buffer drawn in Web Mercator, from 81% of the intended circle in Miami to 23% in Anchorage. Right: a map of downtown Calgary with the true 3-mile circle holding 225,880 residents and the smaller Web Mercator buffer holding 135,388

Downtown Calgary: dashed black is a true 3-mile geodesic circle. Red is a "3-mile" buffer computed in EPSG:3857, which is really 1.89 miles across the ground.

Where does this go wrong in real projects?

The error rarely announces itself, because the output looks plausible. The common routes in:

  1. Data pulled from a web service. Features exported from a web map, a tile service or a JavaScript app often arrive in EPSG:3857. A buffer or area calculation on them runs without warning.
  2. Drawing in the browser. Many web mapping libraries draw circles and measure in screen space, which is Web Mercator. A "3-mile radius" drawn by a client-side tool may be a 3-mile radius in projected units.
  3. Map-based reports. Trade-area rings, protected territories and coverage circles drawn on a web map and then summarised for population. In Calgary the error above removed 40% of the residents. That is larger than the gap between a ring and a drive-time catchment in my Calgary trade-area test, so a projection mistake can swamp the real analytical question.
  4. Densities and rates per square kilometre. Dividing by an EPSG:3857 area understates density by the area factor: 2.5 times in Calgary, 1.9 times in Toronto.
  5. Grids and hexbins. A "1 km" grid built in EPSG:3857 has cells smaller than 1 km on the ground, and cells at the north of a large study area are smaller than cells at the south. Counts per cell then vary with latitude, not just with the data.

Is latitude and longitude (EPSG:4326) any better?

No, for a different reason. EPSG:4326 stores coordinates as degrees of latitude and longitude. A degree of latitude is always about 111 km, but a degree of longitude shrinks with the cosine of the latitude.

At Calgary, a buffer of 0.05 degrees becomes an ellipse 5.56 km tall and 3.51 km wide. Areas computed in "square degrees" have no fixed meaning at all. GeoPandas warns about this when you call .area or .buffer on a geographic CRS, and the warning is worth reading.

Degrees are a good storage format. They are not a measuring unit.

Which CRS should you use instead?

The right choice depends on how large the study area is.

Study areaBest optionTypical scale error
A city, county or small regionIts UTM zone, or the official local system: a US State Plane zone, or a provincial system such as Alberta 3TMWell under 1 part in 1,000
A state, province or countryAn equal-area projection for areas (for example Albers equal-area conic), or an equidistant one for distances from a centreZero for the preserved property, small for others
A continent or the worldGeodesic calculation on the ellipsoidNone, by definition
Display onlyWeb MercatorIrrelevant, as long as nothing is measured

Local systems are very accurate over their intended area. At Calgary:

CRSEPSGScale factor at CalgaryError per kilometre
NAD83 / UTM zone 11N269111.00012212 cm
NAD83 / Alberta 3TM, reference meridian 114°W37760.999900−10 cm
WGS 84 / Pseudo-Mercator (Web Mercator)38571.591591 m

Calgary sits at 114.07°W, just west of the boundary between UTM zones 11 and 12 at 114°W. Projects that straddle a zone boundary should pick one zone and stay in it, or use the provincial or state system, which is designed for exactly this.

For Islamabad, UTM zone 43N (EPSG:32643) has a scale factor of 1.000003 at the city centre, an error of 3 mm per kilometre.

How do you measure correctly in common tools?

PostGIS. Cast to geography to measure on the ellipsoid. For the geography type, ST_Area returns square metres computed on a spheroid by default.

-- Geodesic area in km², whatever the stored CRS
SELECT ST_Area(ST_Transform(geom, 4326)::geography) / 1e6 AS area_km2
FROM parcels;

-- A true 3-mile buffer, returned as geometry for display
SELECT ST_Buffer(ST_Transform(geom, 4326)::geography, 4828.032)::geometry AS ring
FROM sites;

-- Or work in a local CRS for a whole city
SELECT ST_Area(ST_Transform(geom, 3776)) / 1e6 AS area_km2
FROM calgary_parcels;

Python (GeoPandas and pyproj). Reproject to a suitable local CRS, or compute geodesic measures directly.

import geopandas as gpd
from pyproj import Geod

gdf = gpd.read_file("sites.gpkg")

# Option 1: a local projected CRS chosen for the data's location
local = gdf.to_crs(gdf.estimate_utm_crs())
local["area_km2"] = local.area / 1e6
local["ring"] = local.buffer(4828.032)           # true 3 miles

# Option 2: geodesic area on the WGS 84 ellipsoid
geod = Geod(ellps="WGS84")
gdf_ll = gdf.to_crs(4326)
gdf_ll["area_km2"] = [abs(geod.geometry_area_perimeter(g)[0]) / 1e6
                      for g in gdf_ll.geometry]

QGIS. Set the project ellipsoid under Project Properties, General, Measurements. The $area and $length expressions in the field calculator then return ellipsoidal values. The area($geometry) function returns planar values in the layer's CRS, which is exactly the trap in an EPSG:3857 layer. For buffers, reproject the layer to a local CRS first.

ArcGIS Pro. The Buffer tool has a method parameter with planar and geodesic options. Use geodesic for data in a geographic CRS or Web Mercator. For areas, the Calculate Geometry Attributes tool offers geodesic area units.

Web apps. Compute buffers and areas on the server or with a geodesic library, then send the result to the map for display. Never treat screen-space or projected distances from the map view as ground distances.

How do you check for this error in existing work?

A quick audit takes minutes:

  1. Check the CRS of every layer used for measurement. If it says 3857, 900913, 3785 or "Pseudo-Mercator", every distance and area derived from it is suspect.
  2. Recompute one known shape. Take a parcel, a park or a city boundary with a published area and compare. In Calgary, a stored area about 2.5 times the official one is the signature of a Web Mercator calculation.
  3. Measure one buffer across the ground. Pick a buffer from the deliverable and measure its radius with a geodesic tool. A 3-mile ring with a 1.9-mile radius at Calgary's latitude gives the game away.
  4. Ask the vendor. A contract deliverable should state the CRS used for analysis, separately from the CRS used for display. If you are writing that contract, the GIS contractor checklist covers what to require.

What should you take from this?

Use Web Mercator to show maps and something else to measure them. For a single city or county, work in its UTM zone or official local system. For anything larger, measure geodesically. And before any buffer, area or density goes into a report, check which CRS it was computed in, because at North American latitudes the wrong answer is off by tens of percent while looking entirely reasonable on the map.

If you need an existing analysis audited for projection errors, or a new one built in the right CRS from the start, email me at mahad.imran29@gmail.com.

Frequently asked questions

Can I measure distance or area in EPSG:3857?

Not directly. Web Mercator stretches distances by a factor of 1/cos(latitude) in every direction, so a measured length is too long by 11% in Miami, 30% in Denver and 59% in Calgary, and areas are too large by the square of that factor. Measure on the ellipsoid (geodesic), or reproject to a local projected CRS such as UTM or a state plane zone first.

Why is my buffer the wrong size on a web map?

If the buffer was computed in EPSG:3857, a distance of 4,828 'metres' is applied in projected units that are smaller than real metres away from the equator. At Calgary's latitude a 3-mile buffer drawn that way has a real radius of 1.89 miles and covers only 40% of the intended area. Compute buffers geodesically or in a local CRS, then display them in Web Mercator.

What coordinate system should I use to calculate area?

For a single city or county, use its UTM zone or the official local system, such as a US State Plane zone or Alberta's 3TM, where scale error is a fraction of a millimetre per metre. For data spanning a country or continent, use an equal-area projection or calculate geodesic area on the ellipsoid, for example PostGIS ST_Area on the geography type.

Is EPSG:4326 better than EPSG:3857 for measurement?

No. EPSG:4326 coordinates are latitude and longitude in degrees, and a degree of longitude shrinks toward the poles. A buffer of 0.05 degrees around Calgary is an ellipse 5.56 km tall and 3.51 km wide. Degrees are fine for storage, but measure geodesically or reproject before using them as distances.

Why do web maps use Web Mercator if it distorts size?

Because it preserves local shape and direction, which matters for street maps, and because it maps the world to a square that divides neatly into the tiles every web map uses. It is a display projection. The mistake is using its coordinates for analysis.

Let's talk.

Best way to reach me is email. I respond to most things.