[PROJ] Affine transformation using DERIVEDPROJCRS

Bart.Duijndam at ziggo.nl Bart.Duijndam at ziggo.nl
Mon Jul 4 02:00:27 PDT 2022


Greetings all,

 

Working with QGIS, I am in need of developing a ‘custom CRS’ with its own origin and orientation. 

Basically I need a CRS that is DERIVED from a PROJCRS, resulting in a DERIVEDPROJCRS.

 

I have done some work to that extent, that can be seen at the following spreadsheet on GitHub:

https://github.com/Duijndam-Dev/TopoLib/blob/master/TopoLib/Samples/DerivedProjectedCrsTests.xlsb

 

Right now, I do this by hacking a WKT2 string, based on various examples found on the internet.

https://gis.stackexchange.com/questions/353022/defining-a-coordinate-system-in-wkt-or-proj-format-that-has-an-affine-transforma 

https://gis.stackexchange.com/questions/350228/define-custom-projection-in-qgis-from-some-control-points 

https://gis.stackexchange.com/questions/408406/qgis-custom-projection-in-wkt-not-saving-prj-file 

https://gis.stackexchange.com/questions/366578/custom-crs-for-historic-site-grid 

https://gis.stackexchange.com/questions/408683/custom-derived-crs-by-affine-transformation-from-epsg32633-setting-as-layer-cr 

 

Doing the required affine transform is relatively straightforward. What is more of a concern is creating a WKT2 string to setup the DERIVEDPROJCRS.

In particular, I would like to preserve the USAGE definition and BBOX field. Any closing ID field needs to be removed, as it is no longer valid.

 

But the process of editing a WKT2 string is rather error prone. It is not something you’d like a ‘novice’ having to do.

Now, the fact is that proj supports affine transforms since v6.0.0. See: https://proj.org/operations/transformations/affine.html?highlight=affine+transformation#

 

Finally, to come to my question: would it be possible to define the following workflow in C++ code:

1.	Create a projected CRS object (from EPSG code, or a WKT string)
2.	Apply an affine transformation on this CRS
3.	Export the modified CRS as a WKT string

This automation would avoid any manual editing of the WKT2 string.

 

Maybe - if this isn’t the best approach - are any other ways conceivable to achieve my goal ?

Much appreciate your advice.

 

 <mailto:Bart.Duijndam at ziggo.nl> Bart Duijndam

Geoscience consultant

www.duijndam.dev <http://www.duijndam.dev/>  

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20220704/91e86983/attachment.htm>


More information about the PROJ mailing list