Hi Danny, shapely.kml is something that I've been meaning to remove. Shapely is just about 2D geometry operations and has wkb and wkt modules so that it can exchange geometry representations with other software. KML is a bit out of this scope.
Generating KML is something I should probably add to my Keytree package: http://sgillies.net/blog/750/keytree/ Currently, keytree just has a method to extract data from a KML placemark element that can then be used by Shapely. Another method that would make etree Elements from a Shapely geometry would be handy, yes? >>> from xml.etree import ElementTree >>> tree = ElementTree.parse(open('archaic.kml', 'rb')) >>> kmlns = tree.getroot().tag.split('}')[0][1:] >>> placemarks = tree.findall('*/{%s}Placemark' % kmlns) >>> p0 = placemarks[0] >>> import keytree >>> f = keytree.feature(p0) >>> from shapely.geometry import asShape >>> shape = asShape(f.geometry) >>> shape.wkt 'POINT (21.9725000000000001 32.8962999999999965)' Potentially round out the trip with >>> placemark = keytree.placemark(id='...', geometry=shape, name='...') Cheers, Sean On Mar 24, 2009, at 9:58 AM, Danny Shevitz wrote: > Howdy, > > I am an absolute newbie to Shapely. I have been perusing the kml > subpackage > and find it completely undocumented. I have also loaded it into > IPython > and since the code is all C, there isn't any guidance there either. > > Can anyone enlighten me as to what the kml subpackage does? Is it > for reading > kml files or writing or both. I need to generate KML, so if the > package can > do that, it would be very useful to me. > > thanks, > Danny > > _______________________________________________ > Community mailing list > [email protected] > http://lists.gispython.org/mailman/listinfo/community _______________________________________________ Community mailing list [email protected] http://lists.gispython.org/mailman/listinfo/community
