I am looking to develop a python script that triggers every time the user zooms or pans to a new map extent. The script I have in mind will clip a raster to the visible extent thus reclassifying the colour ramp and hopefully revealing more subtle anomalies in, for example, a raster of elevation data.
My question is how to go about 'triggering' the script when the view extent is altered by the user. My intention was to access a variable that describes the extent of the currently visible map display in GRASS 7.x. A while loop could be executed that would continuously check this variable for changes and trigger the rest of the script.
I thought the variable could be accessed by the;
command, however this appears to be returning the co-ordinates of the current grass region as opposed to the visible extent of the map.
Problem: I cannot access the visible extent of the map in the monitor display Reproduce: Try to create a python object that contains the visible extent of the map in the monitor display.
After launching grass with the wxGUI I have so far tried launching and selecting a new monitor using the following commands:
import grass.script as grass grass.run_command("d.mon", start='wx0') grass.run_command("d.mon", select='wx0') grass.run_command("d.rast", map='elevation')
This open as new map display window and displays an elevation raster. Then I retrieve some information re the the new display using;
info = grass.read_command("d.info", flags='r') print(info) >> screen rectangle: 0.000000 640.000000 0.000000 480.000000
Then I resize the display window manually and rerun;
info = grass.read_command("d.info", flags='r')
The output remains the same, despite me having manually resized the display window. The same problem occurs when I run d.info with any of its flags though (I'm not entirely sure what each flag does).