TransWikia.com

How to get the affine matrix between 2 projection using pyproj?

Geographic Information Systems Asked on April 20, 2021

I’m struggling getting the affine matrix (or crs_transform) using pyproj. The Transformerobject is full of functions to actually transform coordinates but I just want to check the matrix:

I’m stuck here:

import pyproj 

toto = pyproj.transformer.Transformer.from_crs("EPSG:3857", "EPSG:4326")
toto.to_json()

One Answer

The PROJ library (which is called by the pyproj module) does coordinate transformations and projections for a vast number of different systems. This includes converting lat-long coordinates to many different map projections.

Some of these transformations involve complex trigonometric and geometric calculations - for example projecting lat-long onto a cone wrapped around an earth ellipsoid. That cone can then be "unfurled" to a flat 2-D map. Other transformations are quite simple - the "Plate Caree" projection turns lat-long into X-Y coordinates with a 1:1 aspect ratio.

Most of these transformations cannot be represented by an affine transform, and hence you can't pull out a transformation matrix for a general A->B transformation in PROJ.

One area where you will find affine transformation matrices is in GDAL for raster data. If you have a raster grid for part of the earth then you need to specify the corner pixel coordinates, and this defines an affine transformation from pixel coordinate (R,C) to world coordinate (X,Y), but (X,Y) has to be in the coordinate system of the grid pixels - ie they must be something like 0.2 degree or 30 metre cells.

Correct answer by Spacedman on April 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP