(self, layer, extent, num_across=10)
Creates a grid of hexagon features in `layer`.
Creates a grid of hexagon features in `layer`.
Creates a grid of hexagon features in layer .
def create_grid(self, layer, extent, num_across=10):
        """
        Creates a grid of hexagon features in `layer`.
        """
        definition = layer.GetLayerDefn()
        width = extent[1] - extent[0]
        height = extent[3] - extent[2]
        scale_width = width / num_across

        column = 0
        y = extent[2] - scale_width
        while y < extent[3] + scale_width:
            x = extent[0] - scale_width
            if column % 2 == 0:
                x += 0.75 * scale_width
            while x < extent[1] + scale_width:
                hexagon = self.create_hexagon(x, y, scale_width)
                feature = ogr.Feature(definition)
                feature.SetGeometry(hexagon)
                feature.SetField('COUNT', 0)
                layer.CreateFeature(feature)
                feature.Destroy()
                x += (1.5 * scale_width)
            y += SQRT_3_DIV_4 * scale_width
            column += 1
def create_grid ( self , layer , extent , num_across = 10 ) : definition = layer . GetLayerDefn ( ) width = extent [ 1 ] - extent [ 0 ] height = extent [ 3 ] - extent [ 2 ] scale_width = width / num_across column = 0 y = extent [ 2 ] - scale_width while y < extent [ 3 ] + scale_width : x = extent [ 0 ] - scale_width if column % 2 == 0 : x += 0.75 * scale_width while x < extent [ 1 ] + scale_width : hexagon = self . create_hexagon ( x , y , scale_width ) feature = ogr . Feature ( definition ) feature . SetGeometry ( hexagon ) feature . SetField ( 'COUNT' , 0 ) layer . CreateFeature ( feature ) feature . Destroy ( ) x += ( 1.5 * scale_width ) y += SQRT_3_DIV_4 * scale_width column += 1