# Convert relative coordinates into absolute ones having only one absolute coordinate in QGIS

I have a layer of points with relative altimetric heights from a survey carried out with a Differential GPS. I know the absolute coordinates of only one point (EPSG:4326 WGS 84 ), the other points have coordinates in an arbitrary system.  Is it possible to transform all other relative coordinates into absolute ones based on a single point known with QGIS?

• Just to make sure, are all the black points in your screenshot the points which need to be updated? – Gabriel C. Feb 6 '20 at 14:35
• Yes, that's right! I only know the absolute coordinates of one of them. – ddomizia Feb 6 '20 at 14:38
• And are they located correctly on the map canvas? – Gabriel C. Feb 6 '20 at 14:39
• The shape you see is that of an archaeological site with various elevations, and it is correct. The problem is that since there is no absolute coordinate system I am working locally to create contour lines, but I was asked to place them on a base map to show them in a WebGis and to create plates with metric scale etc.. – ddomizia Feb 6 '20 at 14:48
• Ok, so if I understand correctly, even the point for which you have the absolute XY values is currently placed at an arbitrary position on the map canvas, but relative to all the other points it is correctly placed? – Gabriel C. Feb 6 '20 at 14:54

## 1 Answer

The question was missing a little bit of info but with the dataset in hand, I was able to roughly find out what was going on.

First off, each point is actually composed of 6 different points that each contain a single attribute that belongs to the actual point, which is the one in the middle: You need to isolate the true point with the tool Extract by attribute from the Processing Toolbox:

• Input layer: `original layer`
• Selection attribute: `Layer`
• Operator: `=`
• Value: `0`

The resulting layer can be renamed Points. This tool can be repeated twice, with Value: `ID_punto` and `Quota`. The resulting layers can be renamed to match the values.

Next, use the Join attributes by nearest tool:

• Input layer: `Points`
• Input layer 2: `Quota`
• Layer 2 fields to copy: `Text`
• Joined field prefix: `Quota_`
• Maximum nearest neighbots: `1`

Do this one more time, but in the input layer, use the resulting layer from the previous join attributes so that all the text fields from the surrounding 2 points are added to the true point. Rename the resulting layer to something like Cleaned points.

This cleaned points layer will have many useless fields, so these can be deleted to only keep the 2 important ones like so: The next step is to create two fields containing the X and Y coordinates, relative to your point with known real world coordinates. In the attribute table, go to the Field Calculator:

• Create a new field
• Output field name: `Rel_X`
• Output field type: `Decimal`
• Output field length: `0`
• Expression: `round(\$x - x(geometry( get_feature( 'Cleaned points','ID_Text','1'))),4)`

The result is the rounded (to 4 decimals) distance to the main point in map units along the X axis. Repeat this step to create a field called `Rel_Y`, replacing all the `x` mentions to `y`. The table should look something like this: From here on I'm relying on a certain assumption; that the north of the survey was aligned with geographical north and also that the survey units were meters.

We know the geographic coordinates of the point with ID: `1`, which is:

• 39°42'36.35"N 64°23'5.76"E

Using epsg.io, transform this to UTM Zone 41N (epsg:32641):

• X: `618718.05`
• Y: `4396498.45`

Create two fields, X and Y, in the attribute table (Decimal). For the point with ID `1`, paste the corresponding values. Now we can use the field calculator again to find every point's true coordinate in EPSG:32641:

• Update existing field
• Choose field `X`
• Expression: `round(attribute(get_feature('Cleaned points','ID_Text','1'),'X') + attribute('Rel_X'),4)`

Repeat for the field Y, and now you have a relatively precise location for each of your points. You can now export this layer as a CSV table.

Import that table as a CSV source. In geometry definition:

• point coordinates X field: `X` column
• point coordinates Y field: `Y` column
• Geometry CRS: `EPSG:32641`

The added layer is now positioned correcly on Earth (following the assumptions I made). If you want to use it in applications where only geographical coordinates are supported like Google Earth or on Mapbox, for example, export this layer using WGS84 as the output CRS. The result looks like this: If my assumptions were wrong and the survey's axes were not aligned with geographical north, additional trig steps would be required to get correct coordinates.

• I think I misunderstood: I need to convert the x y coordinates and not the z value. In short I need to get to place the points on a base map like Google Satellite.. – ddomizia Feb 6 '20 at 14:28
• Ah, that's slightly different. Your question mentioned relative heights so that's what I did, but the exact same method can be applied to the X and Y fields. – Gabriel C. Feb 6 '20 at 14:30
• Thank you so much for your help! You've been very kind! – ddomizia Feb 6 '20 at 19:50
• Yes, that's the place. Now all I have to do is apply the procedure and see if the contour lines match with these steps. As soon as I'm done, I'll publish the result. Thanks again. – ddomizia Feb 6 '20 at 19:55
• Your procedure turned out to be correct in the end. The points seem to be wrongly oriented because the person who gave me the coordinates for point 0 was wrong to transcribe them. With the right UTM coordinates for point 1, it all makes sense. Thanks again! – ddomizia Feb 7 '20 at 21:38