示例#1
0
 def _to_multi_init(self, shape_type):
     """!
     @brief Prepare Writer for MultiPoints* Shapefile
     @param shape_type <int>: shape type identifier
     """
     w = shp.MyWriter(
         shapeType=shape_type
     )  # brute-force fix for MultiPointZ- and MultiPointM-writing bug
     for field_name, field_type, field_length, decimal_length in self.fields:
         w.field(field_name, field_type, str(field_length), decimal_length)
     return w
示例#2
0
    def to_multi(self, new_shapes, to_file):
        w = shp.MyWriter(
            shapeType=self.shape_type
        )  # brute-force fix for MultiPointZ- and MultiPointM-writing bug

        for field_name, field_type, field_length, decimal_length in self.fields:
            w.field(field_name, field_type, str(field_length), decimal_length)

        for points, points_m, attributes in zip(new_shapes, self.m,
                                                self.attributes):
            coords = np.array(points)
            new_m = [0 if m is None else m for m in points_m]
            m_flat = np.array(new_m).reshape((coords.shape[0], 1))
            coords = np.hstack((coords, m_flat))
            w.poly(parts=[list(map(tuple, coords))], shapeType=self.shape_type)
            w.record(*attributes)

        w.save(to_file)