Reputation: 7951
I've got a polygon which looks something like this in WKT:
POLYGON ((-2.5079473598836624 51.34385834919997, -2.5081726654409133 51.34353499032948, -2.507909808957454 51.343441165566986, -2.507679138982173 51.34359530614682, -2.5079473598836624 51.34385834919997))
I'm trying to transform this from EPSG:3857 (web mercator) to EPSG:32630 (UTM 30N) to do some distance calculations on it but the results look weird:
wgs_proj = pyproj.CRS("EPSG:3857")
utm_proj = pyproj.CRS("EPSG:32630")
transform = pyproj.Transformer.from_crs(wgs_proj, utm_proj, always_xy=True).transform
shape = shapely.wkt.loads("POLYGON ((-2.5079473598836624 51.34385834919997, -2.5081726654409133 51.34353499032948, -2.507909808957454 51.343441165566986, -2.507679138982173 51.34359530614682, -2.5079473598836624 51.34385834919997))")
boundary = shapely.ops.transform(transform, shape)
print(str(boundary))
This outputs:
POLYGON ((833976.0465009063 51.05017626883035, 833976.04627538 51.04985475944731, 833976.0465384943 51.049761471464706, 833976.0467693905 51.0499147304722, 833976.0465009063 51.05017626883035))
This looks to me like it's got the longitude conversion roughly right but the latitude conversion completely wrong. The units are supposed to be in metres, I think. So unless the shape happens to be at a latitude about 51m North of the origin of UTM30N, something has gone wrong. Can anyone point me to what?
Upvotes: 0
Views: 1374
Reputation: 7951
This is because the data is in long-lats, not in EPSG:3857. Almost everything online says that EPSG:3857 is what Google maps uses, but this is only true internally. EPSG:3857 is WGS84 projected into metres. Externally, Google still uses WGS84 long-lats, ie EPSG:4326. Changing the origin coordinate system in the code shown in the question produces the right result.
Upvotes: 1