1

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()
4
  • Are you sure its an affine transformation? Its going from a sphere earth model to an ellipsoidal one, for one thing...
    – Spacedman
    Apr 5 at 17:49
  • true, but isn't it possible to set a crs_transform matrix from 4326 to 3857 ? Apr 6 at 6:05
  • I don't think so. The only place you usually see affine transformations in coordinate systems is transforming pixel coordinates to real-world coordinates in the coordinate reference system of the pixel grid
    – Spacedman
    Apr 6 at 8:55
  • ok then I need to better understand how transformations works. If you want to add a sum-up in answer I will be happy to mark it as solution Apr 6 at 8:57
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.