15

I have a map with a "strange" projection (it's basically hand-painted, not an exact one). I can easily georeference it in QGIS using the Georeferencer plugin and the Thin Plate Spline transformation with a set of some 2000-3000 control points into simple WGS 84 (EPSG:4326) "latlong" projection and process/enhance it further with other data, like from Natural Earth or OpenStreetMap.

Now I'd like to perform the inverse operation: Transform one of those raster layers (or rasterised vector layers) back into the hand-painted quasi-projection, ideally using the same set of control points, so that the images match when overlaid in a graphic editor. How do I do it?

4
  • 8
    interesting situation. Maybe you don't georeference the hand-painted map at all. Use the hand-painted map as 'ground-truth' and get your control points based on the local coordinate system ( say, top-left corner of hand-painted map is 0,0 and each pixel is a unit ). Then 'georeference' your rasters to this local coordinate system. Commented Jun 1, 2012 at 12:20
  • 1
    @spatialthoughts: This would work for rasters rather well, however I would also lose the precision of vector layers and the possibility to do calculations with them (area of a feature, length of a segment and so on). That's not an insurmountable problem, of course. Being able to reverse the georeferencing just wouldn't have those limitations. Commented Jun 1, 2012 at 13:20
  • @Martin Do you want the vector calculations in WGS84 or in the hand-painted image coordinates? If the former, sounds like your need to transform vectors to the hand-painted coordinates is totally separate from your need to do calculations on the vector -- and I would second spatialthoughts' suggestion. Just means you need to do these tasks in separate QGIS projects.
    – Jeff G
    Commented Jun 11, 2016 at 13:29
  • 1
    In general it's not guaranteed that an inverse exists for all transforms. With polynomial transforms, if you could get the plugin to log the coefficients it used, you could calculate the inverse mathematically. With thin plate spline, maybe an inverse is possible as well: the GDALCreateTPSTransformer function takes a "bReversed" argument: gdal.org/gdal__alg_8h.html#a245802b88a8126c138d24febe6c9822a
    – Jeff G
    Commented Jun 11, 2016 at 13:32

2 Answers 2

1

If you were using ArcGIS, you use the spatial adjustment toolbar. However, QGIS offers a similar functionality through plugins.

Go to the plugin manager and install 'Affine Transformations'

Also install 'Vector Bender'

Homepage: https://github.com/trenneman/qgsAffine;

https://plugins.qgis.org/plugins/VectorBender/

Since you already have the control points, you should be able to transform your data back to the original "projection". Load your control points into the plugin and perform the transformation. I haven't tried this yet so you may have to play with the control points. The affine transformations plugin uses constants to perform the transformation. Since you already have control points, you'll want to use the vector bender to perform a 'rubber sheet'.
Vector bender is not in the plugin repository, so you'll need to install it manually by adding it to C:\Users.qgis2\python\plugins\VectorBender.


Second option (may only work for rasters, haven't tested with vectors) - In the georeferencer, you can save your control points to a file. You can also load control points from a file.

Here is what you need to do:

Save the cpg file. Change the extension to .csv. Open the file in excel. Swap the values in the to/from columns. Save. Change the extension back to .points.

Once you have the control points set up, you can transform back and forth using the control points and your preferred transformation method.

2
  • Isn't the spatial adjustment toolbar part of Arcgis Desktop? I'm not sure there is something similar in QGIS.
    – AndreJ
    Commented Aug 13, 2016 at 15:33
  • @AndreJ Please see my edits.
    – jbalk
    Commented Aug 23, 2016 at 3:43
0

I had to do this myself once for a raster layer and it took me a while to see that I didn't need the inverse. To make images match in the original strange projection, write a script to create a grid in that projection, corresponding to the pixels in your graphics editor. Transform forwards for each point in the grid to pick up the value of the layer you have in WGS 84. (similar to spatialthoughts comment)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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