I have examined some Python scripts on the Arcscripts site and they
seem horribly complicated. For example the script "Convert Files GPS
(KML, GPX) to Shapefiles"  (http://arcscripts.esri.com/details.asp?
dbid=16797) requires 117 lines of code to extract the placemarks and
geometries of a kml file without using any standard module to read
xml.
I think they misrepresent python using only:
"import arcgisscripting"

I sent the following email based on a sample of keytree by Sean
Gillies
"when you read a kml file, why not use the standard modules?
1) to find Placemarks in kml files:
from xml.etree import ElementTree
tree = ElementTree.parse(open('your.kml', 'rb'))
kmlns = tree.getroot().tag.split('}')[0][1:]
placemarks = tree.findall('*/{%s}Placemark' % kmlns)
 and you have all the placemarks
2) using keytree and shapely gives you the geometry
p0 = placemarks[0]
import keytree
f = keytree.feature(p0)
from shapely.geometry import asShape
shape = asShape(f.geometry)
shape.wkt
exemple of results:
'POINT (21.9725000000000001 32.8962999999999965)'"

Reply via email to