Re: [GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-27 Thread Martin Landa
Hi,

2016-03-26 18:52 GMT+01:00 Glynn Clements :
>
> Martin Landa wrote:
>
>> > d.mon is designed for interactive use. If you're writing a script,
>> > don't use it. Set GRASS_RENDER_IMMEDIATE=png (or =cairo) and use the
>> > environment variables.
>>
>> not really, beside wx monitors, you can use cairo or png (useful for
>> scripting). Martin
>
> You appear to be misunderstanding what "interactive" means in this
> context. It doesn't necessarily imply a GUI.

I was just responding to your sentence "If you're writing a script,
don't use it."

> The only situation where a script should be using d.mon is if it
> really is a "script", in the sense of a canned sequence of commands
> which is meant to be "replayed" as part of an interactive workflow.

Right. Ma
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-26 Thread Glynn Clements

Martin Landa wrote:

> > d.mon is designed for interactive use. If you're writing a script,
> > don't use it. Set GRASS_RENDER_IMMEDIATE=png (or =cairo) and use the
> > environment variables.
> 
> not really, beside wx monitors, you can use cairo or png (useful for
> scripting). Martin

You appear to be misunderstanding what "interactive" means in this
context. It doesn't necessarily imply a GUI.

The only situation where a script should be using d.mon is if it
really is a "script", in the sense of a canned sequence of commands
which is meant to be "replayed" as part of an interactive workflow.

Anything which tries to behave like a typical program should manage
the relevant environment variables directly.

-- 
Glynn Clements 
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-11 Thread Glynn Clements

d.mon is designed for interactive use. If you're writing a script,
don't use it. Set GRASS_RENDER_IMMEDIATE=png (or =cairo) and use the
environment variables.

-- 
Glynn Clements 
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-10 Thread Martin Landa
Hi,

2016-03-10 10:14 GMT+01:00 Moritz Lennert :
> Martin has done some serious rewriting of d.mon in trunk (grass71). Too much
> to be backported to the stable branch. I don't know if these things can
> easily be fixed in grass, or whether this is another serious argument to
> release grass sooner rather than later...

backporting is not planned.

> In conclusion, if you want to use d.mon, I suggest you try with grass71 for
> now.

Agreed, Martin

-- 
Martin Landa
http://geo.fsv.cvut.cz/gwiki/Landa
http://gismentors.cz/mentors/landa
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-10 Thread Moritz Lennert

On 10/03/16 09:48, jean pierre huart wrote:

I did it also directly in the terminal and it's the same result.


[...]


With these tests, I have the impression that 'GRASS_RENDER_TRANSPARENT',
'GRASS_RENDER_HEIGHT', 'GRASS_RENDER_WIDTH' are not taken into account
by d.mon.


Thanks for all these tests. Ok, I've just tested and I can confirm that 
there seems to be an issue in grass70. Everything works for me in grass71.


Martin has done some serious rewriting of d.mon in trunk (grass71). Too 
much to be backported to the stable branch. I don't know if these things 
can easily be fixed in grass, or whether this is another serious 
argument to release grass sooner rather than later...


In conclusion, if you want to use d.mon, I suggest you try with grass71 
for now.


Moritz


___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-10 Thread jean pierre huart

I did it also directly in the terminal and it's the same result.
Adding 'width' and 'height' parameters to d.mon has given the expected 
result.


viascript.png PNG 1280x960 1280x960+0+0 8-bit DirectClass 72.7KB 0.000u 
0:00.000


(NB I tried it before unsuccessfully, but I was not deleting the 
existing image, thanks for mentioning it to me).


d.mon still fails for the transparent background.
I used the parameter 'bgcolor' to change the background color, but 
declaring bgcolor='none' give me an error.
'transparent' parameter does not exists. Any idea on which parameter to 
use for such behaviour?


With these tests, I have the impression that 'GRASS_RENDER_TRANSPARENT', 
'GRASS_RENDER_HEIGHT', 'GRASS_RENDER_WIDTH' are not taken into account 
by d.mon.
 I still have to test all this using another location instead of the 
one I've set up.


--
Jean Pierre Huart


On 09/03/16 20:04, Moritz Lennert wrote:

On 09/03/16 18:01, jean pierre huart wrote:

Launching the two scripts directly in GRASS7 console using my
location/mapset give the following results for just one width, height
(1280,960):

Using d.mon (not ok)
viascript.png PNG 640x480 640x480+0+0 8-bit DirectClass 30.5KB 0.000u
0:00.000


I didn't try in the console, but directly in the terminal. Not sure 
how d.mon and wxGUI console interact.


Note that d.mon also has width and height parameters. Have you tried 
with those ?


Moritz



___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-09 Thread Moritz Lennert

On 09/03/16 18:01, jean pierre huart wrote:

Launching the two scripts directly in GRASS7 console using my
location/mapset give the following results for just one width, height
(1280,960):

Using d.mon (not ok)
viascript.png PNG 640x480 640x480+0+0 8-bit DirectClass 30.5KB 0.000u
0:00.000


I didn't try in the console, but directly in the terminal. Not sure how 
d.mon and wxGUI console interact.


Note that d.mon also has width and height parameters. Have you tried 
with those ?


Moritz

___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-09 Thread jean pierre huart
Launching the two scripts directly in GRASS7 console using my 
location/mapset give the following results for just one width, height 
(1280,960):


Using d.mon (not ok)
viascript.png PNG 640x480 640x480+0+0 8-bit DirectClass 30.5KB 0.000u 
0:00.000


With GRASS_RENDER_IMMEDIATE (ok)
viascript2.png PNG 1280x960 1280x960+0+0 8-bit DirectClass 73.6KB 0.000u 
0:00.000


I will test it with the NC demo soon.
Jean Pierre

On 09/03/16 17:44, jean pierre huart wrote:


I launch a script without starting GRASS explicitly on an existing 
location, inspired by the solution proposed at 
https://grasswiki.osgeo.org/wiki/Working_with_GRASS_without_starting_it_explicitly.


I do not have any error in the logs, the image is created, but with 
default size (640x480) and white background.


I will try using the internal script console and give you a feed back 
if it works or not on my location/mapset.


Jean Pierre

On 09/03/16 17:08, Moritz Lennert wrote:

On 09/03/16 16:55, jean pierre huart wrote:

Bingo! Thanks Moritz,

- the existing file... I didn't care about it, convinced that the
--overwrite parameter will wipe it out.


I agree that is a bit confusing (and could maybe be handled better), 
but --overwrite comes into action at the time of writing of the file, 
not at the time of reading the existing RENDER_FILE.



Launching this script in a cron, I've the feeling that the use of
GRASS_RENDER_IMMEDIATE is more appropriate. By the way, the choice is
simple, this solution works fine for me, but using d.mon does not.


What does not work with d.mon ? Does my below script work for you (it 
uses the NC demo data set [1]) ?


Moritz

[1] https://grass.osgeo.org/download/sample-data/




Ciao

On 09/03/16 16:12, Moritz Lennert wrote:

On 09/03/16 15:39, jean pierre huart wrote:

Thanks Vinay, for the suggestion but I get an error on the d.out.file
instruction.
By the way, I've investigated the problem a bit further and found 
that I

mixed up instructions from manuals of different versions.
So coming back to GRASS v 7.0.x references I finally succeed in
obtaining a solution but not 100% satisfactory.

First trial create a unique image combining raster and vector, but 
width

and height remains at default and background is not transparent:

  os.environ['GRASS_RENDER_TRANSPARENT'] = 'TRUE'
  os.environ['GRASS_RENDER_WIDTH'] = str(1280)
  os.environ['GRASS_RENDER_HEIGHT'] = str(960)
  os.environ['GRASS_RENDER_FILE'] = filenameCombined.png

  self.gscript.run_command('d.mon', overwrite=True, start='png',
output=filename)
  self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset)
  self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')
  self.gscript.run_command('d.mon', stop="png")


Second trial successfull for obtaining desired width, height and
transparency of the background  but creating 2 images one for the 
raster
and the other for the vector, now I would like to combine them to 
have

only one image:

  os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
  os.environ['GRASS_RENDER_TRANSPARENT'] = 'TRUE'
  os.environ['GRASS_RENDER_WIDTH'] = str(1280)
  os.environ['GRASS_RENDER_HEIGHT'] = str(960)

  os.environ['GRASS_RENDER_FILE'] = filenameOfRaster.png
  self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset))

  os.environ['GRASS_RENDER_FILE'] = filenameOfVector.png
  self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')

Modifying this with the following

  os.environ['GRASS_RENDER_FILE'] = filenameCombined.png
  self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset))
  self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')

ends with only the image of the vector.

I've the feeling that using d.mon would be preferable, but it 
seems that

it does not take into account the environment variables (at the
exception of GRASS_RENDER_FILE) that I propose.


This script gives me differently sized png files with both maps
displayed and transparent background:

import grass.script as gscript
import os

os.environ['GRASS_RENDER_TRANSPARENT']='TRUE'

for height in range(500,2000,500):
 for width in range(500,2000,500):

 os.system('rm map.png')
 os.environ['GRASS_RENDER_HEIGHT']=str(height)
 os.environ['GRASS_RENDER_WIDTH']=str(width)

 gscript.run_command('d.mon', overwrite=True, start='png',
output='map.png')
 gscript.run_command('d.rast', map_='elevation')
 gscript.run_command('d.vect', map_='roadsmajor')
 gscript.run_command('d.mon', stop="png")

 os.system('identify map.png')


You can reach the same result with something like this:

import grass.script as gscript
import os

os.environ['GRASS_RENDER_TRANSPARENT']='TRUE'

for height in range(500,2000,500):

Re: [GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-09 Thread jean pierre huart


I launch a script without starting GRASS explicitly on an existing 
location, inspired by the solution proposed at 
https://grasswiki.osgeo.org/wiki/Working_with_GRASS_without_starting_it_explicitly.


I do not have any error in the logs, the image is created, but with 
default size (640x480) and white background.


I will try using the internal script console and give you a feed back if 
it works or not on my location/mapset.


Jean Pierre

On 09/03/16 17:08, Moritz Lennert wrote:

On 09/03/16 16:55, jean pierre huart wrote:

Bingo! Thanks Moritz,

- the existing file... I didn't care about it, convinced that the
--overwrite parameter will wipe it out.


I agree that is a bit confusing (and could maybe be handled better), 
but --overwrite comes into action at the time of writing of the file, 
not at the time of reading the existing RENDER_FILE.



Launching this script in a cron, I've the feeling that the use of
GRASS_RENDER_IMMEDIATE is more appropriate. By the way, the choice is
simple, this solution works fine for me, but using d.mon does not.


What does not work with d.mon ? Does my below script work for you (it 
uses the NC demo data set [1]) ?


Moritz

[1] https://grass.osgeo.org/download/sample-data/




Ciao

On 09/03/16 16:12, Moritz Lennert wrote:

On 09/03/16 15:39, jean pierre huart wrote:

Thanks Vinay, for the suggestion but I get an error on the d.out.file
instruction.
By the way, I've investigated the problem a bit further and found 
that I

mixed up instructions from manuals of different versions.
So coming back to GRASS v 7.0.x references I finally succeed in
obtaining a solution but not 100% satisfactory.

First trial create a unique image combining raster and vector, but 
width

and height remains at default and background is not transparent:

  os.environ['GRASS_RENDER_TRANSPARENT'] = 'TRUE'
  os.environ['GRASS_RENDER_WIDTH'] = str(1280)
  os.environ['GRASS_RENDER_HEIGHT'] = str(960)
  os.environ['GRASS_RENDER_FILE'] = filenameCombined.png

  self.gscript.run_command('d.mon', overwrite=True, start='png',
output=filename)
  self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset)
  self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')
  self.gscript.run_command('d.mon', stop="png")


Second trial successfull for obtaining desired width, height and
transparency of the background  but creating 2 images one for the 
raster

and the other for the vector, now I would like to combine them to have
only one image:

  os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
  os.environ['GRASS_RENDER_TRANSPARENT'] = 'TRUE'
  os.environ['GRASS_RENDER_WIDTH'] = str(1280)
  os.environ['GRASS_RENDER_HEIGHT'] = str(960)

  os.environ['GRASS_RENDER_FILE'] = filenameOfRaster.png
  self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset))

  os.environ['GRASS_RENDER_FILE'] = filenameOfVector.png
  self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')

Modifying this with the following

  os.environ['GRASS_RENDER_FILE'] = filenameCombined.png
  self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset))
  self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')

ends with only the image of the vector.

I've the feeling that using d.mon would be preferable, but it seems 
that

it does not take into account the environment variables (at the
exception of GRASS_RENDER_FILE) that I propose.


This script gives me differently sized png files with both maps
displayed and transparent background:

import grass.script as gscript
import os

os.environ['GRASS_RENDER_TRANSPARENT']='TRUE'

for height in range(500,2000,500):
 for width in range(500,2000,500):

 os.system('rm map.png')
 os.environ['GRASS_RENDER_HEIGHT']=str(height)
 os.environ['GRASS_RENDER_WIDTH']=str(width)

 gscript.run_command('d.mon', overwrite=True, start='png',
output='map.png')
 gscript.run_command('d.rast', map_='elevation')
 gscript.run_command('d.vect', map_='roadsmajor')
 gscript.run_command('d.mon', stop="png")

 os.system('identify map.png')


You can reach the same result with something like this:

import grass.script as gscript
import os

os.environ['GRASS_RENDER_TRANSPARENT']='TRUE'

for height in range(500,2000,500):
 for width in range(500,2000,500):

 os.system('rm map.png')
 os.environ['GRASS_RENDER_IMMEDIATE']='png'
 os.environ['GRASS_RENDER_FILE']='map.png'
 os.environ['GRASS_RENDER_FILE_READ']='TRUE'
 os.environ['GRASS_RENDER_HEIGHT']=str(height)
 os.environ['GRASS_RENDER_WIDTH']=str(width)

 gscript.run_command('d.rast', map_='elevation')
 gscript.run_command('d.vect', map_='roadsmajor')

 

Re: [GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-09 Thread Moritz Lennert

On 09/03/16 16:55, jean pierre huart wrote:

Bingo! Thanks Moritz,

- the existing file... I didn't care about it, convinced that the
--overwrite parameter will wipe it out.


I agree that is a bit confusing (and could maybe be handled better), but 
--overwrite comes into action at the time of writing of the file, not at 
the time of reading the existing RENDER_FILE.



Launching this script in a cron, I've the feeling that the use of
GRASS_RENDER_IMMEDIATE is more appropriate. By the way, the choice is
simple, this solution works fine for me, but using d.mon does not.


What does not work with d.mon ? Does my below script work for you (it 
uses the NC demo data set [1]) ?


Moritz

[1] https://grass.osgeo.org/download/sample-data/




Ciao

On 09/03/16 16:12, Moritz Lennert wrote:

On 09/03/16 15:39, jean pierre huart wrote:

Thanks Vinay, for the suggestion but I get an error on the d.out.file
instruction.
By the way, I've investigated the problem a bit further and found that I
mixed up instructions from manuals of different versions.
So coming back to GRASS v 7.0.x references I finally succeed in
obtaining a solution but not 100% satisfactory.

First trial create a unique image combining raster and vector, but width
and height remains at default and background is not transparent:

  os.environ['GRASS_RENDER_TRANSPARENT'] = 'TRUE'
  os.environ['GRASS_RENDER_WIDTH'] = str(1280)
  os.environ['GRASS_RENDER_HEIGHT'] = str(960)
  os.environ['GRASS_RENDER_FILE'] = filenameCombined.png

  self.gscript.run_command('d.mon', overwrite=True, start='png',
output=filename)
  self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset)
  self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')
  self.gscript.run_command('d.mon', stop="png")


Second trial successfull for obtaining desired width, height and
transparency of the background  but creating 2 images one for the raster
and the other for the vector, now I would like to combine them to have
only one image:

  os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
  os.environ['GRASS_RENDER_TRANSPARENT'] = 'TRUE'
  os.environ['GRASS_RENDER_WIDTH'] = str(1280)
  os.environ['GRASS_RENDER_HEIGHT'] = str(960)

  os.environ['GRASS_RENDER_FILE'] = filenameOfRaster.png
  self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset))

  os.environ['GRASS_RENDER_FILE'] = filenameOfVector.png
  self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')

Modifying this with the following

  os.environ['GRASS_RENDER_FILE'] = filenameCombined.png
  self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset))
  self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')

ends with only the image of the vector.

I've the feeling that using d.mon would be preferable, but it seems that
it does not take into account the environment variables (at the
exception of GRASS_RENDER_FILE) that I propose.


This script gives me differently sized png files with both maps
displayed and transparent background:

import grass.script as gscript
import os

os.environ['GRASS_RENDER_TRANSPARENT']='TRUE'

for height in range(500,2000,500):
 for width in range(500,2000,500):

 os.system('rm map.png')
 os.environ['GRASS_RENDER_HEIGHT']=str(height)
 os.environ['GRASS_RENDER_WIDTH']=str(width)

 gscript.run_command('d.mon', overwrite=True, start='png',
output='map.png')
 gscript.run_command('d.rast', map_='elevation')
 gscript.run_command('d.vect', map_='roadsmajor')
 gscript.run_command('d.mon', stop="png")

 os.system('identify map.png')


You can reach the same result with something like this:

import grass.script as gscript
import os

os.environ['GRASS_RENDER_TRANSPARENT']='TRUE'

for height in range(500,2000,500):
 for width in range(500,2000,500):

 os.system('rm map.png')
 os.environ['GRASS_RENDER_IMMEDIATE']='png'
 os.environ['GRASS_RENDER_FILE']='map.png'
 os.environ['GRASS_RENDER_FILE_READ']='TRUE'
 os.environ['GRASS_RENDER_HEIGHT']=str(height)
 os.environ['GRASS_RENDER_WIDTH']=str(width)

 gscript.run_command('d.rast', map_='elevation')
 gscript.run_command('d.vect', map_='roadsmajor')

 os.system('identify map.png')


You might have to watch out for existing files. If a file already
exists with the indicated name then GRASS cannot change its width and
height.

Hope this helps,
Moritz


___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user




___
grass-user mailing list
grass-user@lists.osgeo.org

Re: [GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-09 Thread jean pierre huart

Bingo! Thanks Moritz,

- the existing file... I didn't care about it, convinced that the 
--overwrite parameter will wipe it out.
- os.environ['GRASS_RENDER_FILE_READ']='TRUE' to pile layers in one 
file, I thought it was only to import the first layer from an existing 
image.


Launching this script in a cron, I've the feeling that the use of 
GRASS_RENDER_IMMEDIATE is more appropriate. By the way, the choice is 
simple, this solution works fine for me, but using d.mon does not.


Ciao

On 09/03/16 16:12, Moritz Lennert wrote:

On 09/03/16 15:39, jean pierre huart wrote:

Thanks Vinay, for the suggestion but I get an error on the d.out.file
instruction.
By the way, I've investigated the problem a bit further and found that I
mixed up instructions from manuals of different versions.
So coming back to GRASS v 7.0.x references I finally succeed in
obtaining a solution but not 100% satisfactory.

First trial create a unique image combining raster and vector, but width
and height remains at default and background is not transparent:

 os.environ['GRASS_RENDER_TRANSPARENT'] = 'TRUE'
 os.environ['GRASS_RENDER_WIDTH'] = str(1280)
 os.environ['GRASS_RENDER_HEIGHT'] = str(960)
 os.environ['GRASS_RENDER_FILE'] = filenameCombined.png

 self.gscript.run_command('d.mon', overwrite=True, start='png',
output=filename)
 self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset)
 self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')
 self.gscript.run_command('d.mon', stop="png")


Second trial successfull for obtaining desired width, height and
transparency of the background  but creating 2 images one for the raster
and the other for the vector, now I would like to combine them to have
only one image:

 os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
 os.environ['GRASS_RENDER_TRANSPARENT'] = 'TRUE'
 os.environ['GRASS_RENDER_WIDTH'] = str(1280)
 os.environ['GRASS_RENDER_HEIGHT'] = str(960)

 os.environ['GRASS_RENDER_FILE'] = filenameOfRaster.png
 self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset))

 os.environ['GRASS_RENDER_FILE'] = filenameOfVector.png
 self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')

Modifying this with the following

 os.environ['GRASS_RENDER_FILE'] = filenameCombined.png
 self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset))
 self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')

ends with only the image of the vector.

I've the feeling that using d.mon would be preferable, but it seems that
it does not take into account the environment variables (at the
exception of GRASS_RENDER_FILE) that I propose.


This script gives me differently sized png files with both maps 
displayed and transparent background:


import grass.script as gscript
import os

os.environ['GRASS_RENDER_TRANSPARENT']='TRUE'

for height in range(500,2000,500):
for width in range(500,2000,500):

os.system('rm map.png')
os.environ['GRASS_RENDER_HEIGHT']=str(height)
os.environ['GRASS_RENDER_WIDTH']=str(width)

gscript.run_command('d.mon', overwrite=True, start='png', 
output='map.png')

gscript.run_command('d.rast', map_='elevation')
gscript.run_command('d.vect', map_='roadsmajor')
gscript.run_command('d.mon', stop="png")

os.system('identify map.png')


You can reach the same result with something like this:

import grass.script as gscript
import os

os.environ['GRASS_RENDER_TRANSPARENT']='TRUE'

for height in range(500,2000,500):
for width in range(500,2000,500):

os.system('rm map.png')
os.environ['GRASS_RENDER_IMMEDIATE']='png'
os.environ['GRASS_RENDER_FILE']='map.png'
os.environ['GRASS_RENDER_FILE_READ']='TRUE'
os.environ['GRASS_RENDER_HEIGHT']=str(height)
os.environ['GRASS_RENDER_WIDTH']=str(width)

gscript.run_command('d.rast', map_='elevation')
gscript.run_command('d.vect', map_='roadsmajor')

os.system('identify map.png')


You might have to watch out for existing files. If a file already 
exists with the indicated name then GRASS cannot change its width and 
height.


Hope this helps,
Moritz


___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-09 Thread Moritz Lennert

On 09/03/16 15:39, jean pierre huart wrote:

Thanks Vinay, for the suggestion but I get an error on the d.out.file
instruction.
By the way, I've investigated the problem a bit further and found that I
mixed up instructions from manuals of different versions.
So coming back to GRASS v 7.0.x references I finally succeed in
obtaining a solution but not 100% satisfactory.

First trial create a unique image combining raster and vector, but width
and height remains at default and background is not transparent:

 os.environ['GRASS_RENDER_TRANSPARENT'] = 'TRUE'
 os.environ['GRASS_RENDER_WIDTH'] = str(1280)
 os.environ['GRASS_RENDER_HEIGHT'] = str(960)
 os.environ['GRASS_RENDER_FILE'] = filenameCombined.png

 self.gscript.run_command('d.mon', overwrite=True, start='png',
output=filename)
 self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset)
 self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')
 self.gscript.run_command('d.mon', stop="png")


Second trial successfull for obtaining desired width, height and
transparency of the background  but creating 2 images one for the raster
and the other for the vector, now I would like to combine them to have
only one image:

 os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
 os.environ['GRASS_RENDER_TRANSPARENT'] = 'TRUE'
 os.environ['GRASS_RENDER_WIDTH'] = str(1280)
 os.environ['GRASS_RENDER_HEIGHT'] = str(960)

 os.environ['GRASS_RENDER_FILE'] = filenameOfRaster.png
 self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset))

 os.environ['GRASS_RENDER_FILE'] = filenameOfVector.png
 self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')

Modifying this with the following

 os.environ['GRASS_RENDER_FILE'] = filenameCombined.png
 self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster,
currentmapset))
 self.gscript.run_command('d.vect', map='{0}@{1}'.format(map,
currentmapset), color='white', fill_color='none')

ends with only the image of the vector.

I've the feeling that using d.mon would be preferable, but it seems that
it does not take into account the environment variables (at the
exception of GRASS_RENDER_FILE) that I propose.


This script gives me differently sized png files with both maps 
displayed and transparent background:


import grass.script as gscript
import os

os.environ['GRASS_RENDER_TRANSPARENT']='TRUE'

for height in range(500,2000,500):
for width in range(500,2000,500):

os.system('rm map.png')
os.environ['GRASS_RENDER_HEIGHT']=str(height)
os.environ['GRASS_RENDER_WIDTH']=str(width)

gscript.run_command('d.mon', overwrite=True, start='png', 
output='map.png')

gscript.run_command('d.rast', map_='elevation')
gscript.run_command('d.vect', map_='roadsmajor')
gscript.run_command('d.mon', stop="png")

os.system('identify map.png')


You can reach the same result with something like this:

import grass.script as gscript
import os

os.environ['GRASS_RENDER_TRANSPARENT']='TRUE'

for height in range(500,2000,500):
for width in range(500,2000,500):

os.system('rm map.png')
os.environ['GRASS_RENDER_IMMEDIATE']='png'
os.environ['GRASS_RENDER_FILE']='map.png'
os.environ['GRASS_RENDER_FILE_READ']='TRUE'
os.environ['GRASS_RENDER_HEIGHT']=str(height)
os.environ['GRASS_RENDER_WIDTH']=str(width)

gscript.run_command('d.rast', map_='elevation')
gscript.run_command('d.vect', map_='roadsmajor')

os.system('identify map.png')


You might have to watch out for existing files. If a file already exists 
with the indicated name then GRASS cannot change its width and height.


Hope this helps,
Moritz
___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Re: [GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-09 Thread jean pierre huart
Thanks Vinay, for the suggestion but I get an error on the d.out.file 
instruction.
By the way, I've investigated the problem a bit further and found that I 
mixed up instructions from manuals of different versions.
So coming back to GRASS v 7.0.x references I finally succeed in 
obtaining a solution but not 100% satisfactory.


First trial create a unique image combining raster and vector, but width 
and height remains at default and background is not transparent:


os.environ['GRASS_RENDER_TRANSPARENT'] = 'TRUE'
os.environ['GRASS_RENDER_WIDTH'] = str(1280)
os.environ['GRASS_RENDER_HEIGHT'] = str(960)
os.environ['GRASS_RENDER_FILE'] = filenameCombined.png

self.gscript.run_command('d.mon', overwrite=True, start='png', 
output=filename)
self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster, 
currentmapset)
self.gscript.run_command('d.vect', map='{0}@{1}'.format(map, 
currentmapset), color='white', fill_color='none')

self.gscript.run_command('d.mon', stop="png")


Second trial successfull for obtaining desired width, height and 
transparency of the background  but creating 2 images one for the raster 
and the other for the vector, now I would like to combine them to have 
only one image:


os.environ['GRASS_RENDER_IMMEDIATE'] = 'png'
os.environ['GRASS_RENDER_TRANSPARENT'] = 'TRUE'
os.environ['GRASS_RENDER_WIDTH'] = str(1280)
os.environ['GRASS_RENDER_HEIGHT'] = str(960)

os.environ['GRASS_RENDER_FILE'] = filenameOfRaster.png
self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster, 
currentmapset))


os.environ['GRASS_RENDER_FILE'] = filenameOfVector.png
self.gscript.run_command('d.vect', map='{0}@{1}'.format(map, 
currentmapset), color='white', fill_color='none')


Modifying this with the following

os.environ['GRASS_RENDER_FILE'] = filenameCombined.png
self.gscript.run_command('d.rast', map='{0}@{1}'.format(raster, 
currentmapset))
self.gscript.run_command('d.vect', map='{0}@{1}'.format(map, 
currentmapset), color='white', fill_color='none')


ends with only the image of the vector.

I've the feeling that using d.mon would be preferable, but it seems that 
it does not take into account the environment variables (at the 
exception of GRASS_RENDER_FILE) that I propose.


If you have other suggestions to go further I'll be very gratefull.
Ciao

--
Jean Pierre Huart



On 09/03/16 05:10, Vinay Elothunkal wrote:

Hi jean pierre huart,

I have exported png image using module "d.out.file",(I have pasted a 
part of the script below which I have used. I hope this will help you

...
import grass.script as g
import os
import shutil
import time
g.run_command('r.colors',map=str(i),rules='color_table.txt')
   g.start_command('d.mon', start='wx1')
   time.sleep(10)
   g.run_command('d.rast', map=str(i))
   time.sleep(10)
   g.run_command('d.vect', map=str(i))
   time.sleep(40)
 g.run_command('d.out.file',output=str(i),format='png',size=(2403,2403))
   time.sleep(10)
   g.run_command('d.mon', stop='wx1')
   time.sleep(10)
.

Regards,
Vinay



___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

[GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-08 Thread Vinay Elothunkal
Hi jean pierre huart,

I have exported png image using module "d.out.file",(I have pasted a part
of the script below which I have used. I hope this will help you
...
import grass.script as g
import os
import shutil
import time
g.run_command('r.colors',map=str(i),rules='color_table.txt')
 g.start_command('d.mon', start='wx1')
 time.sleep(10)
 g.run_command('d.rast', map=str(i))
 time.sleep(10)
 g.run_command('d.vect', map=str(i))
 time.sleep(40)

 g.run_command('d.out.file',output=str(i),format='png',size=(2403,2403))
 time.sleep(10)
 g.run_command('d.mon', stop='wx1')
 time.sleep(10)
.

Regards,
Vinay


>
>1. How to define the png image dimensions when using d.mon?
>   (jean pierre huart)
>2. Re: How to define the png image dimensions when using d.mon?
>   (jean pierre huart)
>
>
> --
>
> Message: 1
> Date: Tue, 8 Mar 2016 16:15:01 +0100
> From: jean pierre huart <j...@openjph.be>
> To: grass-user@lists.osgeo.org
> Subject: [GRASS-user] How to define the png image dimensions when
> using   d.mon?
> Message-ID: <56deec75.5030...@openjph.be>
> Content-Type: text/plain; charset=iso-8859-15; format=flowed
>
> Hello,
>
> I've written a python script to generate an image combining a vector map
> (myvector) and a raster (myraster) that has been generated using a mask.
> It works great by default and creates an image with the default
> dimensions 640x480 on a white background.
>
>  gscript.run_command('d.mon', overwrite=True, start='png',
> output=filename)
>  gscript.run_command('d.rast', map='{0}@{1}'.format(myraster,
> self.mapset))
>  gscript.run_command('d.vect', map='{0}@{1}'.format(myvector,
> self.mapset), color='white', fill_color='none')
>  gscript.run_command('d.mon', stop="png")
>
> I would like to have a transparent background and to change the
> dimensions of the image to 1280x960.
> Reading the documentation I had the impression that I just have to
> modify some variables, but it does not work.
>
>  os.environ['GRASS_TRANSPARENT'] = 'TRUE'
>  os.environ['GRASS_WIDTH'] = str(1280)
>  os.environ['GRASS_HEIGHT'] = str(960)
>  gscript.run_command('d.mon', overwrite=True, start='png',
> output=filename)
>  gscript.run_command('d.rast', map='{0}@{1}'.format(myraster,
> self.mapset))
>  gscript.run_command('d.vect', map='{0}@{1}'.format(myvector,
> self.mapset), color='white', fill_color='none')
>  gscript.run_command('d.mon', stop="png")
>
> Thanks in advance for any advice.
> Ciao
>
> --
> Jean Pierre Huart
>
>
>
> ----------
>
> Message: 2
> Date: Tue, 8 Mar 2016 16:28:35 +0100
> From: jean pierre huart <j...@openjph.be>
> To: grass-user@lists.osgeo.org
> Subject: Re: [GRASS-user] How to define the png image dimensions when
> using d.mon?
> Message-ID: <56deefa3.2050...@openjph.be>
> Content-Type: text/plain; charset=utf-8; format=flowed
>
> Sorry I've forgotten to precise that I'm using Grass v7.0.3 on ubuntu
> 14.04.
>
> On 08/03/16 16:15, jean pierre huart wrote:
> > Hello,
> >
> > I've written a python script to generate an image combining a vector
> > map (myvector) and a raster (myraster) that has been generated using a
> > mask.
> > It works great by default and creates an image with the default
> > dimensions 640x480 on a white background.
> >
> > gscript.run_command('d.mon', overwrite=True, start='png',
> > output=filename)
> > gscript.run_command('d.rast', map='{0}@{1}'.format(myraster,
> > self.mapset))
> > gscript.run_command('d.vect', map='{0}@{1}'.format(myvector,
> > self.mapset), color='white', fill_color='none')
> > gscript.run_command('d.mon', stop="png")
> >
> > I would like to have a transparent background and to change the
> > dimensions of the image to 1280x960.
> > Reading the documentation I had the impression that I just have to
> > modify some variables, but it does not work.
> >
> > os.environ['GRASS_TRANSPARENT'] = 'TRUE'
> > os.environ['GRASS_WIDTH'] = str(1280)
> > os.environ['GRASS_HEIGHT'] = str(960)
> > gscript.run_command('d.mon', overwrite=True, start='png',
> > output=filename)
> > gscript.run_comma

Re: [GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-08 Thread jean pierre huart

Sorry I've forgotten to precise that I'm using Grass v7.0.3 on ubuntu 14.04.

On 08/03/16 16:15, jean pierre huart wrote:

Hello,

I've written a python script to generate an image combining a vector 
map (myvector) and a raster (myraster) that has been generated using a 
mask.
It works great by default and creates an image with the default 
dimensions 640x480 on a white background.


gscript.run_command('d.mon', overwrite=True, start='png', 
output=filename)
gscript.run_command('d.rast', map='{0}@{1}'.format(myraster, 
self.mapset))
gscript.run_command('d.vect', map='{0}@{1}'.format(myvector, 
self.mapset), color='white', fill_color='none')

gscript.run_command('d.mon', stop="png")

I would like to have a transparent background and to change the 
dimensions of the image to 1280x960.
Reading the documentation I had the impression that I just have to 
modify some variables, but it does not work.


os.environ['GRASS_TRANSPARENT'] = 'TRUE'
os.environ['GRASS_WIDTH'] = str(1280)
os.environ['GRASS_HEIGHT'] = str(960)
gscript.run_command('d.mon', overwrite=True, start='png', 
output=filename)
gscript.run_command('d.rast', map='{0}@{1}'.format(myraster, 
self.mapset))
gscript.run_command('d.vect', map='{0}@{1}'.format(myvector, 
self.mapset), color='white', fill_color='none')

gscript.run_command('d.mon', stop="png")

Thanks in advance for any advice.
Ciao



--
Jean Pierre Huart

OpenJph
19, rue de la fontaine
1340 Ottignies
web: www.openjph.be
email: j...@openjph.be
tel:   +32 487 95 77 75
skype: jeanpierre.huart

___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

[GRASS-user] How to define the png image dimensions when using d.mon?

2016-03-08 Thread jean pierre huart

Hello,

I've written a python script to generate an image combining a vector map 
(myvector) and a raster (myraster) that has been generated using a mask.
It works great by default and creates an image with the default 
dimensions 640x480 on a white background.


gscript.run_command('d.mon', overwrite=True, start='png', 
output=filename)
gscript.run_command('d.rast', map='{0}@{1}'.format(myraster, 
self.mapset))
gscript.run_command('d.vect', map='{0}@{1}'.format(myvector, 
self.mapset), color='white', fill_color='none')

gscript.run_command('d.mon', stop="png")

I would like to have a transparent background and to change the 
dimensions of the image to 1280x960.
Reading the documentation I had the impression that I just have to 
modify some variables, but it does not work.


os.environ['GRASS_TRANSPARENT'] = 'TRUE'
os.environ['GRASS_WIDTH'] = str(1280)
os.environ['GRASS_HEIGHT'] = str(960)
gscript.run_command('d.mon', overwrite=True, start='png', 
output=filename)
gscript.run_command('d.rast', map='{0}@{1}'.format(myraster, 
self.mapset))
gscript.run_command('d.vect', map='{0}@{1}'.format(myvector, 
self.mapset), color='white', fill_color='none')

gscript.run_command('d.mon', stop="png")

Thanks in advance for any advice.
Ciao

--
Jean Pierre Huart

___
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user