I have created a shapely object (i.e. the_pt) for my Points & Multipoints to do a buffer analysis against another shapely object (i.e. city_pt) using:

  return_shapes = []
  for pt in points:
            # create a shapely obj of all the points
            the_pt = shape(pt['geometry'])
            # what type of geometry is it?
            geom = pt['geometry']
            # check if it is a multipoint or point
            if geom['type'] == 'MultiPoint':
                # i.e. <class 'shapely.geometry.multipoint.MultiPoint'>
                pts = []
                for m_pt in the_pt:
                    city_pt_buffer = city_pt.buffer(dist)
                    # city_pt is a shapely obj
                    if m_pt.within(city_pt_buffer):
            # check if it is a point geom
            elif geom['type'] == 'Point':
                    city_pt_buffer = city_pt.buffer(dist)
                    if the_pt.within(city_pt_buffer):
        return return_shapes

If I evaluate pt - I have a dict type with the geometry and properties needed to map to shapefile...

 <type 'dict'>
    {'geometry': {'type': 'Point', 'coordinates': (-13649075.348882342, 6193380.937753927)}, 'type': 'Feature', 'id': '7', 'properties': OrderedDict([(u'OBJECTID', 68547), (u'ISO', u'USA'), (u'SITE_NAME', u'Anacortes')])}

however what I really want is 'return_shapes' to be written to shapefile (with all the properties...Is there anyway to build return_shapes (a list) into something I can write (map) into a shapefile format?


The Fiona user manual has an example of creating a shapefile and writing exactly this kind of feature dict: http://toblerity.org/fiona/manual.html#writing-new-files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.