def modify_polygon(self, pid, polygon, value):
        """Modify parts of a parameter set by setting all parameters located
        in, or touching, the provided :class:`shapely.geometry.Polygon`
        instance.

        Parameters
        ----------
        pid: int
            id of parameter set to vary
        polygon: :class:`shapely.geometry.Polygon` instance
            polygon that determines the area to modify
        value: float
            value that is assigned to all elements in the polygon

        Examples
        --------
        >>> import shapely.geometry
            polygon = shapely.geometry.Polygon((
                (2, 0), (4, -1), (2, -1)
            ))
            tdman.parman.modify_polygon(pid, polygon, 3)

        """
        # create grid polygons
        grid_polygons = []
        for x, z in zip(self.grid.grid['x'], self.grid.grid['z']):
            coords = [(a, b) for a, b in zip(x, z)]
            grid_polygons.append(
                shapgeo.Polygon(coords)
            )

        # now determine elements in area
        elements_in_area = []
        for nr, element in enumerate(grid_polygons):
            if polygon.contains(element):
                elements_in_area.append(nr)
            elif polygon.equals(element):
                elements_in_area.append(nr)
            elif polygon.crosses(element):
                elements_in_area.append(nr)
                # only take crossed elements with at least A % overlap
                # int_area = polygon.intersect(element).area
                # print('overlap: ',
                #       int_area,
                #       element.area,
                #       element.area / int_area
                #       )

        # change the values
        pid_clean = self._clean_pid(pid)
        self.parsets[pid_clean][elements_in_area] = value