Getting Coordinates from KMZ

9,509 views
Skip to first unread message

CommanderSven

unread,
Jun 9, 2010, 9:52:14 PM6/9/10
to KML Developer Support - Getting Started with KML
Hey, I just received a batch of about 100 .kmz files and I was
wondering if there was any quick way to get the GPS coordinates for
each one without having to open each up and record it from inside
google earth. Thanks.

nicodemussunrise

unread,
Jun 9, 2010, 11:23:03 PM6/9/10
to KML Developer Support - Getting Started with KML
Commander,

KMZ files are just zip files with a different file extension, so you
can open them with any zip reader (winzip, winrar, gunzip, etc).
Assuming you're on windows, you can do the following:

1. Unzip all the KMZs to KMLs into some directory
2. Run a search on the entire directory for "<coordinates>" in the
contents of all files. (<coordinates> is the XML tag within KML that
holds the longitude,latitude,altitude for a point, in that order)

on linux/OSX:
2. just grep all files for 'coordinates'

Hope that helps

-ns

CommanderSven

unread,
Jun 16, 2010, 12:04:11 PM6/16/10
to KML Developer Support - Getting Started with KML
How exactly do I search the contents of all the files. I try just
using the Windows Search but that doesn't come up with anything. Is
there a 3rd party program i need to use?

Thanks

Josh L

unread,
Jun 18, 2010, 2:59:08 PM6/18/10
to KML Developer Support - Getting Started with KML
Hi there,

This is a bit out of the scope of KML specifically, but generally
there's a number of ways to search within text files. For example,
some text editors (such as notepad++ for windows) can search within
all files in a folder. In addition you could install 'grep' on
windows as a command line utility, or write a little script (using for
example python, and maybe even libkml) to loop over each file and pull
out the bits you are interested in.

Cheers,

-Josh

BobJordanB

unread,
Jun 24, 2010, 7:48:12 AM6/24/10
to KML Developer Support - Getting Started with KML
In addition to Josh's comments you can do it all in Microsoft Word.

Load it into GE and then select the kml code segment you want and do a
CTRL Click then Copy

This will get the kml in ttext form and it can be pasted into a word
processor or text editor

Then using wild card search and replaces in Word you can delete all
the stuff you don't need

So: Search for <LookAt>*/LookAt> with wild cards turned on and replace
with nothing - this will delete all the Lookat sequences

You can quickly work through to be left with the stuff you want

You can automate this using macros if you want to do it more often.

But save the file often as you work through and use different names
each time so you can backstep.

You will learn a lot about word and a lot about kml.

That was how i got into the field

Bob J.
Reply all
Reply to author
Forward
0 new messages