4

I have a KML-file with a path in Google Earth that is slightly displaced. And I don't want to move each coordinate manually.

How can I move all of the coordinates together?

I think this site is using the same kml as I do. It depicts a city wall that is off. It should be moved like 100meters to the south so it don't crosses the major road that is north of it (as it does now). Or if you want to be more precise, each nod is of by longitude 0,000182 and lattitude 0,001217 if my calculation is right.

3
  • What are the parameters of the displacement (or the nature of it, at least)?
    – Martin F
    Commented Jan 11, 2014 at 15:36
  • @martinf I edited my question to be more clear. Commented Jan 11, 2014 at 17:32
  • The kml data format is pretty straight forward so I might write some script to manipulate each node. But it really should be a better way? Commented Jan 11, 2014 at 17:40

2 Answers 2

1

You could do this using ogr2ogr, with the help of a sql query parsed through spatialite.

ogr2ogr translated_kml.kml original.kml -dialect sqlite -sql "SELECT ShiftCoordinates(geometry,x,y) FROM world"

Where x and y are what you want to shift by, in the units of the kml file.

2
  • Perfect, also in the Ubuntu reositary. No I just need to find some time to try it. What would this do to do to the altitude? Commented Jan 12, 2014 at 15:10
  • It would depend on what the elevations for the features are set to. If they are set to 'clamp to ground' then they will just be adjusted to fit the ground elevation at the new location.
    – DPierce
    Commented Jan 13, 2014 at 15:11
0

Because KML coordinates are geodetic, a rigorous solution with known rotation-scale-translation parameters would require use of a geodetic computation engine, such as can be found in PostGIS (which is not "just" a spatial DBMS).

However, your needs indicate that a simple (crude) treatment of the lon-lat coordinates as though they were planar (i.e., 2D cartesian) coordinates would be adequate. Here's how I've accomplished exactly the same:

copy and paste the coordinate string to a text editor

globally edit them to simple CSV format

import the CSV coordinates to a COGO program (such as Copan)

do the transformation

export the transformed coordinates

do the "reverse" edit-reformat-re-paste back into KML

1
  • (i have trouble with numbered lists!)
    – Martin F
    Commented Jan 11, 2014 at 19:15

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.