qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.43k stars 2.99k forks source link

[Georeferencer] Georeferencing vector data #41300

Closed roya0045 closed 2 years ago

roya0045 commented 3 years ago

Feature description.

When importing data without coordinate refenre system, such as CAD drawings, it is tedious to georeference the data, you must set the scale, then transform, then rorate, then transform again until everything is fine.

I forgot that arcthing had a tool for this https://desktop.arcgis.com/en/arcmap/10.3/manage-data/editing-existing-features/about-spatial-adjustment.htm

The georeferencer is currently based on gdalwarp which currently only supports raster data, but I think that by using the deformation in gdal it could be used to handle vector data. Though I'm not sure if this should be a feature request in gdal itself associated with this.

But I think that once we have a good alg to handle this it shouldn't be too hard to do the georeferencer tweaks in QGIS.

uclaros commented 3 years ago

I have modified the exported .points file and used it as a control point file in v.rectify in the past with great results (that's one more reason the flat text format of .points files is useful!).

roya0045 commented 3 years ago

@uclaros Grass naming is truly unintuitive... But rectify would be a good solution as a backend alg. Though the gdal doc also had two functions that could possibly be used as hinted by https://github.com/OSGeo/gdal/blob/0e1b63bd059b7d258fd2a6ac86ccde0011779830/gdal/alg/gdalwarpkernel.cpp#L907

Though the gdal codebase is too much low-level stuff for me, I think the transformers could be reused as relying on grass is not always guaranteed.

At least this proves that this is quite doable with Grass and possibly GDAL.

agiudiceandrea commented 3 years ago

If you only need to translate the geometries, you could use native:translategeometry algorithm. A good plugin was Vector Bender https://plugins.qgis.org/plugins/VectorBender/ by @olivierdalang. It's now problably outdated but it could be a starting point.

roya0045 commented 3 years ago

@agiudiceandrea There is no reliable way to rotate, scale and translate at once with current algs, this is exactly my point.

roya0045 commented 3 years ago

@uclaros ogr2ogr -gcp options seems to work perfectly. It should be adaptable fairly easily. The only limit is the reduced amount of transformation. Which should not matter as much. I'll try to see if I can put out something eventually.

@nyalldawson @nirvn If I try to do something, what would be the best option regarding UI, should it be a distinct tool or integrated in the current one and just alter the dialogs based on the input? Your guidance on this would be welcome.

roya0045 commented 3 years ago

At first glance, only georef main window and the transform settings need to be modified. Working on an integrated approach to reduce code duplication, can't foresee any issues ATM.

roya0045 commented 3 years ago

Ok I think I have most of it down, just need to lear to deal with the gdal api for the call.

roya0045 commented 3 years ago

@uclaros If you want to test the branch is https://github.com/roya0045/QGIS_1/tree/Vector_georef, if you want to give it a try as I'm trying to sort out my linux build. I can't compile due to qgscodeeditor (something is very broken and I have no clue what, errors make no sense).

roya0045 commented 3 years ago

@andreasneumann Please see the post above, though the build is not working yet, should be soon if VM cooperates.

Ok found build issue, missing ; will try to test soon.