KML coordinates conversion

530 views
Skip to first unread message

loo...@gmail.com

unread,
Apr 25, 2007, 5:14:21 PM4/25/07
to KML Support - Advanced Support
Aloha,
I want to convert KML latitude, longitude values from coordinates tag
into values that would be more suitable for 3D program to create a
polygon. For instance, I draw a polygon in GE, export it to KML and I
get 13.40265012586265,52.49297153964929,0 values for a vertice.
Another vertice would be with a difference of 0.000001 .Now, how to
convert those vertices so that they would have x,y values like 120,
30 ? Does anyone knows, or has some links to math that needs to be
done here, or some kind of converter maybe. Hope I explained it
clearly :)
saludos!

//Marcin

Dr. E. B.

unread,
Apr 25, 2007, 10:31:25 PM4/25/07
to KML Support - Advanced Support
I think I would use a spreadsheet and make functions to change the
numbers. You could choose one point as your "zero" and subtract those
coordinates from the others. For example if you had 13.40265,
52.49297 and used that as your zero then you would subtract those
numbers from all your points, so 13.40277, 52.49307 would become
0.00012, 0.00010

You could include in the function a multiplier to give you whole
numbers, say 100,000 so the above would yield 2 points of 0,0 and
12,10

laPlaya

unread,
Apr 26, 2007, 6:19:29 AM4/26/07
to KML Support - Advanced Support
Hola E.B
Thanks for your response, the thing is that I did exactly as you say
before, if I calculate it and mulitply by 100,000 I got distorted
polygons, For instance for square I get a rectangle.( Im making
polygons in GE in sizes of real buildings). I think something more
here is required that those simple operations.Hope someone knows the
trick.
saludos!

ManoM

unread,
Apr 26, 2007, 11:48:32 AM4/26/07
to KML Support - Advanced Support
Hi Marcin,

Is you concern getting numbers that match non-decimal degrees? Or just
getting whole numbers?

ManoM

scruge

unread,
Apr 26, 2007, 12:30:37 PM4/26/07
to KML Support - Advanced Support
You'll need to convert decimal degrees to radians first and either use
"Haversign", "Great Circle" , Spherical Trig" or "Laws of cosines" to
make the calculation. I've been using the "Haversign" calculations
which seem to give me reasonable accuracy, down to fractions of a
meter.

> > 12,10- Hide quoted text -
>
> - Show quoted text -

laPlaya

unread,
Apr 26, 2007, 2:51:46 PM4/26/07
to KML Support - Advanced Support
Aloha
ManoM : Im sorry, I didnt fully understand what you meant. I want to
have numbers(vertices coordinates) that would be suitable for use in
3Dmax for instance. so the points with given long/lati in KML should
respond to vertice 45,111,0 after conversion.

scruge : Thanks a lot for the pointers, those are kind of things that
I needed. but now a question is. When I calculate the distance from
the formulas. I got just the distance - and I would like the
coordinates. For instance the first vertice of the first polygon that
Im parsing from KML will be the world pivot. (0,0,0) but what about
next vertice? I can calculate the distance between world pivot and
this vertice, but what about direction that I should move it to with
this distance (in the end I want a location like x,y,z from 0,0,0
world pivot)?.. any ideas on that? I actually do not need the "z"
coordinate so what Im thinking, is that maybe it is possible to find
formulas for calculating latitude and longitude independently and then
make a vertice x - latitude, y - longitude out of it. (it can be done
by using orthogonal projection I think - I dont know is that the
proper name :).

saludos

//Marcin

scruge

unread,
Apr 26, 2007, 11:36:06 PM4/26/07
to KML Support - Advanced Support
There are several good sources out there. You might try this one out
for starters.
http://www.movable-type.co.uk/scripts/LatLong.html
Use the Bearing and Distance to Lat / Long to calculate your
coordinates.
Make sure to view the page's source code. It should help answer most
of your questions.

> > > - Show quoted text -- Hide quoted text -

scruge

unread,
Apr 27, 2007, 12:13:20 AM4/27/07
to KML Support - Advanced Support
Note, when using distance make sure to convert to radians. Ex. if you
want to plot a point 1 kilometer from the origin, you'll need to
divide 1KM / 6371 and use the result in the calculations. 6371KM is
the radius of the earth. If your unit of measure is miles you would
divide your distance by the earth's radius in miles.
You'll also have to convert your bearing as well.

Function endp // calculate the end point Lat/Long
para f_lt1, f_lg1,f_dst, f_brng // origin Lat / Long
distination's bearing and distance
rlt1=dtor(f_lt1) // convert Lat 1 to radians
rlg1=dtor(f_lg1) // convert Long 1 to radians
rbrng=dtor(f_brng) // convert 360degree bearing to radians
sdst=sin(f_dst) // sine of the distance
cdst=cos(f_dst) // cosine of the distance
slt1=sin(rlt1) // sine of the lat in radians
clt1=cos(rlt1) // cosine of the lat in radians
varlt2=asin(slt1 * cdst + clt1 * sdst * cos(rbrng)) // Lat of
distination once converted from radians back to degrees
varlg2=rlg1 + atn2(sin(rbrng) * sdst * clt1, cdst-slt1 *
sin(varlt2)) // Long of distination once converted from radians back
to degrees

return str(rtod(varlt2),12,7)+","+str(rtod(varlg2),12,7)


On Apr 26, 1:51 pm, laPlaya wrote:

> > > - Show quoted text -- Hide quoted text -

laPlaya

unread,
Apr 28, 2007, 9:06:45 AM4/28/07
to KML Support - Advanced Support
hey scruge, thanks again for the pointers, I studied the topic deeper
and here is what i found. The problem is not so simple and actaully
there is no way to produce maps without distortions these days
(country size). The most popular is UTM (Universal Transverse
Mercator) with is an extended version of Mercator projection
introduced in XVI century. Mercator is a projection of spheroid onto
Cylinder (the equator areas are almost true, polar areas are
multiplied by 9:). But for the problem I have - i need a city
representation - I find old plannar projection most suitable - the
type is called gnomic projection. I specify the tangent point of
spheroid with plane as the first coordinate found in KML and use it as
a world pivot. then I can calculate the cartesian x,y coordinates by
projecting this areas onto plane. here you can find formulas
http://mathworld.wolfram.com/GnomonicProjection.html . it works really
fine - just tested distortions for germany, spain etc. Saludos!

Marcin

scruge

unread,
May 1, 2007, 9:32:28 PM5/1/07
to KML Developer Support - Advanced Support
I agree it isn't simple given the earth isn't a perfect sphere and
ground terrain.

Here's a link to my program that maps wireless network's rf signals
using GE's polys.
http://www.rjpi.com/knsgem.htm

Each of the irregular shaped polys requires more than 5000 floating
point calcs each. To draw 2000 such polys and port them to a KML takes
about 10 secs. The slowest part comes when loading them into GE,
which takes nearly a minute.
<grin>

On Apr 28, 8:06 am, laPlaya wrote:
> hey scruge, thanks again for the pointers, I studied the topic deeper
> and here is what i found. The problem is not so simple and actaully
> there is no way to produce maps without distortions these days
> (country size). The most popular is UTM (Universal Transverse
> Mercator) with is an extended version of Mercator projection
> introduced in XVI century. Mercator is a projection of spheroid onto
> Cylinder (the equator areas are almost true, polar areas are
> multiplied by 9:). But for the problem I have - i need a city
> representation - I find old plannar projection most suitable - the
> type is called gnomic projection. I specify the tangent point of
> spheroid with plane as the first coordinate found in KML and use it as
> a world pivot. then I can calculate the cartesian x,y coordinates by

> projecting this areas onto plane. here you can find formulashttp://mathworld.wolfram.com/GnomonicProjection.html. it works really

Reply all
Reply to author
Forward
0 new messages