Opened 6 years ago

Last modified 5 years ago

#3834 new enhancement

Add .save() method to pygrass.gis.region.Region

Reported by: pmav99 Owned by: grass-dev@…
Priority: normal Milestone: 7.8.3
Component: PyGRASS Version: svn-trunk
Keywords: Cc:
CPU: Unspecified Platform: Unspecified

Description

The Region() objects are missing a method for saving the Region settings to a Region file. As a result, it is not really possible to use WIND_OVERRIDE with Region objects without resorting to use g.region. The following snippet is a possible implementation of a save() method:

    def save(self, filename):
        """
        Save the Region settings to the specified Region file.

        This is the equivalent of `g.region save=filename --overwrite`

        The region file will be created inside the `$MAPSET/windows` directory.
        """
        if not grass.legal_name(filename):
            raise ValueError("Illegal filename: %s", filename)
        self.adjust()
        ret = libgis.G_put_element_window(self.byref(), "windows", filename)
        if ret < 0:
            raise ValueError("Couldn't save the region settings at: %s", filename)

Change History (6)

comment:1 by martinl, 6 years ago

Milestone: 7.8.0

comment:2 by neteler, 6 years ago

Should this go into lib/python/pygrass/gis/region.py ?

comment:3 by neteler, 5 years ago

Milestone: 7.8.07.8.1

Ticket retargeted after milestone closed

comment:4 by neteler, 5 years ago

Milestone: 7.8.17.8.2

Ticket retargeted after milestone closed

comment:5 by neteler, 5 years ago

Milestone: 7.8.2

Ticket retargeted after milestone closed

comment:6 by neteler, 5 years ago

Milestone: 7.8.3
Note: See TracTickets for help on using tickets.