Hot answers tagged


Shapely deals with geometric objects, not features or collections of features. See the manual on shape(). Your code (with JSON) could be: import json from shapely.geometry import shape f = open('wijken.json', 'r') js = json.load(f) f.close() for f in js['features']: s = shape(f['geometry']) ...


You can open the file with OGR and access the points from the layer: from osgeo import ogr ds = ogr.Open('KML_samples.kml') for lyr in ds: for feat in lyr: geom = feat.GetGeometryRef() if geom != None: for i in range(0, geom.GetPointCount()): print (geom.GetPoint(i))


Thanks to the comment of Taras, I found the answer. The coordinates can be extracted based on Shapely commands, i.e. by using p.geometry.x, p.geometry.y


Yes, you can absolutely merge and consolidate Styles in a KML file. It's often the first thing I do when customizing a KML generated by Google Earth (which often has duplicates or other unnecessary styles). All you have to do is put your new simplified, shared styles in the top level Document, and then ensure that the styleUrl in each Feature (Placemark, ...


kml is a xml language focused on geographic visualization, with attention to annotation of maps/images and the navigation of them. For this reason a python script utilizing an xml parser such as xml.etree.ElementTree should be able to extract the coordinates in a fairly straightforward manner. Understanding that for line strings they are identified by the &...


To get some line and polygons into shapely I used My Maps at, exported it as KML and then used this little function: def ExtractPoints(kml): rv = {} ns = "{}" tree = ElementTree() tree.parse(kml) for placemark in tree.findall(".//" + ns + "Placemark"): name = placemark.findtext(ns + "name") ...

Only top voted, non community-wiki answers of a minimum length are eligible