# Import KML file data inside FormFunction (Interpreter problem?)

I have a KML file with a bunch of (lat,lon) pairs. I can retrieve the pairs by importing the KML file as "Data" and drilling down into it:

Import["mykml.kml","Data"][[1,2,2,1,1]]


This yields a GeoPosition object with the (lat,lon) points. Passing this to GeoDistance calculates the length of the path, which is what I'm after.

Now I want to CloudDeploy a FormFunction so other folks can run GeoDistance on their own KML files; something like

form = FormFunction["yourfile" -> "KML", GeoDistance[#yourfile] &]
CloudDeploy[form, Permissions -> "Public"]


The problem is that the FormFunction imports the KML file without the extra "Data" specifier, so that #yourfile is some map object instead of a data structure I can drill down into.

How can I tell FormFunction to import the "Data" in the KML file, and not perform the default importing action?

• Does my answer fit your needs? – Kuba Jun 15 '17 at 7:02
• Yes, it works like a charm. Many thanks! – ConvexMartian Jun 15 '17 at 13:56

You can import plain text and then ImportString:
form = FormFunction[