[GRASS-user] [d.*] command not executing from standalone script

Anna Petrášová kratochanna at gmail.com
Thu Jan 5 06:55:43 PST 2017


Hi Ang,

if you are building a gui application then you should use a different
approach, and integrate the map window in your app and not use
monitors at all. Look for example at g.gui.rlisetup - in the wizard
select a raster map and  'Draw the sampling frame' and you will get a
new page with embedded map window. See
https://trac.osgeo.org/grass/browser/grass/trunk/gui/wxpython/rlisetup/sampling_frame.py#L87
for implementation. This specific example might be more complicated
than what you need. It depends what kind of functionality you want, is
just display enough?

Anna

On Thu, Jan 5, 2017 at 1:43 AM, Ang Sherpa <angsherpa232 at gmail.com> wrote:
> Thanks Martin for your response. Actually, cairo is good idea, however, what
> I am trying to do is building an app. I have already invested lots of my
> time developing interactive gui as shown in the attached screenshot. My
> ultimate plan with grass gis is mentioned in the red-box in attached
> screenshot.
>
> I have a feeling that this process should work as expected.
> 1. Isn't there any way to make grass gis run in background or some kind of
> temporary directory?
> 2. Is there any way that can run the GRASS GIS COMMAND SHELL without running
> the wxgui?
> 2. Interestingly in d.mon document it says that  "The desired monitor should
> be started once and need not be restarted unless it is stopped for some
> reason. A monitor may continue to run for any length of time, even when no
> GRASS session is being run." But don't know what these exactly means if
> working through standalone script.
>
> I will be really grateful if you could show me some way to make this work.
> Will be looking forward to hearing from you.
>
>
>
> Regards,
> Ang Dawa Sherpa
> GIS technician - Irrigation Master Plan
> WRPPF - DOI, Nepal Government
> Lalitpur
> contact: 984 007 3861
>
> On Wed, Jan 4, 2017 at 5:02 PM, Martin Landa <landa.martin at gmail.com> wrote:
>>
>> Hi,
>>
>> 2017-01-04 11:59 GMT+01:00 Ang Sherpa <angsherpa232 at gmail.com>:
>> > My script work from "Launch Script" command within Grass Gis
>> > environment.
>> > However, as a standalone script it just executes nothing not even error.
>> > So,
>> > sleep.time(2) is also not working as expected. Am I missing something?
>> > I have attached the script that I used herewith this mail.
>> >
>> > Will be looking forward to hearing from you.
>>
>> interactive monitors require running GRASS. It is probably reason why
>> wx monitor is not even launched since your script already terminates
>> (and GRASS session too). It has no reason to use interactive monitors
>> outside of GRASS. If you modify your script like:
>>
>> gscript.run_command('d.mon', stop='wx6') # we asssume that there is
>> already monitors hanging from last run
>> gscript.run_command('d.mon',start='wx6',resolution='1')
>> time.sleep(2)
>> gscript.run_command('d.rast',map='elevation')
>> time.sleep(200)
>> os.remove(rcfile)
>>
>> Then monitor shows and will running 200sec. But it has no sense. So I
>> suggest you to use:
>>
>> 1) file-based monitors (which is natural for script, generate
>> something, render to file and close)
>>
>> script.run_command('d.mon',start='cairo',resolution='1',
>> output="/path/image.png")
>> # no need to sleep
>> gscript.run_command('d.rast',map='elevation')
>> gscript.run_command('d.mon', stop='cairo')
>>
>> or
>>
>> 2) launch your script from running GRASS
>>
>> Ma
>>
>> --
>> Martin Landa
>> http://geo.fsv.cvut.cz/gwiki/Landa
>> http://gismentors.cz/mentors/landa
>
>
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user


More information about the grass-user mailing list