Accessing .KMZ contents from VB.Net

1,358 views
Skip to first unread message

Bob Heitzman

unread,
Dec 23, 2011, 12:15:12 PM12/23/11
to kml-suppor...@googlegroups.com
I have to use a ESRI REST service that returns GE data as a KMZ file. Problem is the ESRI service does a poor job of setting styles and it has upper limits depending on the service that cause request to fail unexpectedly. I'd like to be able to read the KML and extract the the placemarks I need and build my own KML file to display.

Problem is the kmz format is a bit strange and none of the standard .Net routines cna handle it easily.

Has anyone seen some working VB code (not C#) that can extract the contents of a KMZ file?

GTrek

unread,
Dec 24, 2011, 5:41:44 AM12/24/11
to KML Developer Support - Advanced Support for KML
Hi Bob

The DOT.NET zip utilities should open KMZ files, what sort of problems
are you encountering and can you provide a sample KMZ?

Regards

John
www.gtrek.co.uk


On Dec 23, 5:15 pm, Bob Heitzman wrote:
> I have to use a ESRI REST service that returns GE data as a KMZ file.
> Problem is the ESRI service does a poor job of setting styles and it has
> upper limits depending on the service that cause request to fail
> unexpectedly. I'd like to be able to read the KML and extract the the
> placemarks I need and build my own KML file to display.
>
> Problem is the kmz format is a bit strange and none of the standard .Net
> routines cna handle it easily.
>
> Has anyone seen some working *VB* code (not C#) that can extract the

Bob Heitzman

unread,
Dec 24, 2011, 12:18:46 PM12/24/11
to kml-suppor...@googlegroups.com
I guess a library is the only way to go... The .Net support deals with individual streams while the KMZ/ZIP have an internal structure that has to be dealt with.

I wound up using Process.Start and launched 7Zip to create a file I could read. I don't know if this would work generically but it works OK with the  KMZs created by ESRI - at least the few I've dealt with so far.

Bob Heitzman

unread,
Dec 28, 2011, 10:27:41 AM12/28/11
to kml-suppor...@googlegroups.com
FYI the code:

            Dim p As New Process
            p.StartInfo.UseShellExecute = False
            p.StartInfo.FileName = PathTo7z_exe
            p.StartInfo.Arguments = "e -y " & KMZFilePath
            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden ' not working
            p.StartInfo.RedirectStandardOutput = True
            p.StartInfo.WorkingDirectory = IO.Directory.GetParent(KMZFilePath).ToString
            p.Start()
            p.WaitForExit()
            Dim output As String = p.StandardOutput.ReadToEnd()
...
            Application.DoEvents()

...

        Dim rk As Microsoft.Win32.RegistryKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\7-Zip")
        PathTo7z_exe = rk.GetValue("Path") & "\7z.exe"

Berwyn

unread,
Feb 4, 2012, 3:11:57 AM2/4/12
to kml-suppor...@googlegroups.com
check out  http://sharpkml.codeplex.com/

I started using this recently for kml generation, havn`t used the parsing yet, but the generation is great
Reply all
Reply to author
Forward
0 new messages