Re: [GRASS-user] r.mapcalculator
Hello On 24/10/2010 19:29, ALT SHN wrote: Regarding your first question, (convert floating point raster to integer) you can use: r.mapcalc "int_raster = int(fp_raster) Hello users, I really could use some hints regarding this problem. I want to generate a new raster from the following _expression_ (using r.mapcalculator from QGIS GRASS plugin): A*0.5+B*0.05+C*0.2+D*0.2+E*0.05 All rasters are integer16 geotiff anda have the same resolution. I just get this message: r.mapcalculator ama...@permanent bma...@permanent cma...@permanent dma...@permanent ema...@permanent = formula=A*0.5+B*0.05+C*0.2+D*0.2+E*0.05 outfile=Erosao Here, I think you want to skip the '@' character. BTW, you can just run the above straight within r.mapcalc also: r.mapcalc "Erosao = A*0.5 + B*0.05 + C*0.2 + D*0.2 + E*0.05" r.mapcalc "Erosao" = "( " "a...@permanent" @PERMANENT" *0.5+ " "b...@permanent" @PERMANENT" *0.05+ " "c...@permanent" @PERMANENT" *0.2+ " "d...@permanent" @PERMANENT" *0.2+ " "e...@permanent" @PERMANENT" *0.05)" Illegal filename. Character not allowed. Invalid map Parse error Calculating Erosao. Try expert mode. Finished with error I suspect something very basic is missing but I dont know what could it be!! Andre -- --- Associao Leonel Trindade SOCIEDADE DE HISTRIA NATURAL Apartado 25 2564-909 Torres Vedras Portugal Sede e Biblioteca: rua Cavaleiros da Espora Dourada, 27A 2560 Torres Vedras Laboratrio de Paleontologia e Paleoecologia: Polgono Industrial do Alto do Ameal 2565-641 Ramalhal http://alt-shn.blogspot.com www.alt-shn.org This mail was received via Mail-SeCure System. ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user This mail was received via Mail-SeCure System. -- Micha Silver http://www.surfaces.co.il/ Arava Development Co. +972-52-3665918 ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] Creating training areas map to be used in i.gensig
Greetings I have 5 raster maps each one represents a training area for a land-use/cover class. I wanted to know what is the best method merge into a single training map to be used in i.gensig? Thanks Luisa ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Check if a raster map has any valid pixel
Thank Glynn. But how can I retrieve min and max using a Python Script? 2010/10/25 Glynn Clements gl...@gclements.plus.com Kim Besson wrote: I have a python script where I need to check if an input raster map has any valid pixel (at least one pixel that is not null). How can I check this (easy and quick way?) in order to be integrated in my Script? Check the range: $ r.mapcalc --o 'foo = null()' $ r.info -r foo min=NULL max=NULL The range can only have min=max=NULL if there are no non-null cells. -- Glynn Clements gl...@gclements.plus.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] pb. with netCDF row order
Nicolas, I've been struggling with the issue of row order in netCDF files and your post came perfect for me. Thank you very much for it. I still have a problem that surely you or anyone in the list would find trivial: the file I'm trying to convert (downloadable in the Prudence project: http://prudence.dmi.dk/data/seasonal/KNMI/t2m.mean.KNMI.HA2.nc.gz ) has four time bands, which I can't write separately into different ascii files. I'm using the script as... ./nc2grass-0001.bin t2m.mean.KNMI.HA2.nc t2m 1 100 1 80 t2m.txt ...and the four time (seasonal) bands came together in the same ascii line. Should I use any additional argument with the script to be able to get four separate ascii files? Thanks a lot! -- Dr. Eduardo Corbelle Rico Associate Researcher Research Group 1934-TeBio - Land Lab. Dept. Agric. Forest Engineering University of Santiago de Compostela (SPAIN) e-mail: eduardo.corbe...@usc.es Tel: +34 982252303 ext. 23292 Fax: +34 982285926 Web: http://laborate.usc.es ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] Error with r.mapcalc
I have a Python script with the following: # Conversion to at-sensor brightness temperature grass.mapcalc($raster_file= $K2/log(($K1/$L)+1), raster_file=raster_file, K2=K2, K1=K1,L= tempL) grass.mapcalc($raster_file= if($raster_file 0, null(), $raster_file), raster_file=raster_file) When it runs the second grass.mapcalc I get the following error: ERROR: Unable to close raster map ERROR: An error occurred while running r.mapcalc Why am I obtaining this error? and How can I avoid it? Thanks Antonio __ Information from ESET NOD32 Antivirus, version of virus signature database 5563 (20101026) __ The message was checked by ESET NOD32 Antivirus. http://www.eset.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] Check if a covariance matrix is invertible- in a Python Script
Greetings I'm building a script where I need to check if a raster map covariance matrix is invertible. How can I do this? Is it possible? Thanks Luisa ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Check if a raster map has any valid pixel
Kim Besson wrote: I have a python script where I need to check if an input raster map has any valid pixel (at least one pixel that is not null). How can I check this (easy and quick way?) in order to be integrated in my Script? Check the range: $ r.mapcalc --o 'foo = null()' $ r.info -r foo min=NULL max=NULL The range can only have min=max=NULL if there are no non-null cells. Thank Glynn. But how can I retrieve min and max using a Python Script? import grass.script as grass def isempty(map): kv = grass.parse_command('r.info', flags = 'r', map = map) return kv['min'] == 'NULL' and kv['max'] == 'NULL' [CC'd to grass-dev] You can't use grass.raster_info() as it tries to convert min and max to floats, and raises ValueError on NULL. r44049 fixes this, and returns None, but this should be considered unstable. Arguably, it should be NaN, but AFAICT that would require Python = 2.6, and I don't want to impose that requirement just for this. For now, r44049 at least suffices for the case where you don't care about min/max (i.e. you can still get the bounds and resolution even if the range is null). If you actually use min/max, r44049 just moves the exception from the call to raster_info() to the point where you try to perform arithmetic operations on None. -- Glynn Clements gl...@gclements.plus.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] Error with r.mapcalc
António Rocha wrote: I have a Python script with the following: # Conversion to at-sensor brightness temperature grass.mapcalc($raster_file= $K2/log(($K1/$L)+1), raster_file=raster_file, K2=K2, K1=K1,L= tempL) grass.mapcalc($raster_file= if($raster_file 0, null(), $raster_file), raster_file=raster_file) When it runs the second grass.mapcalc I get the following error: ERROR: Unable to close raster map ERROR: An error occurred while running r.mapcalc Why am I obtaining this error? and How can I avoid it? Because you're using the same map as both input and output, which won't work. Either use a temporary name for the intermediate map, or replace the second grass.mapcalc call with r.null, e.g.: grass.run_command('r.null', setnull = '-2147483647--1') -- Glynn Clements gl...@gclements.plus.com ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
[GRASS-user] Buffer overflow
Hi all, I did discover a buffer overflow in r.sunmask. I've been testing it on two different machines with 6.4.0 and 6.4RC6 GRASS 64bit Ubuntu On MacOS X SnowLeopard it is working with packages of Kyngchaos Are there any workarounds to quickly solve the problems? cheers, Christian r.sunmask elev=luxdem_raised out=dem_raised.sunmask year=2010 month=6 day=21 hour=12 min=0 sec=0 timezone=1 --o Using map center coordinates: 6.155731 49.625460 Calculating sun position... (using solpos (V. 11 April 2001) from NREL) Calculating shadows from DEM... *** buffer overflow detected ***: r.sunmask terminated === Backtrace: = /lib/libc.so.6(__fortify_fail+0x37)[0x7f5fb6043217] /lib/libc.so.6(+0xfe0d0)[0x7f5fb60420d0] /lib/libc.so.6(+0xfd539)[0x7f5fb6041539] /lib/libc.so.6(_IO_default_xsputn+0xcc)[0x7f5fb5fb9d1c] /lib/libc.so.6(_IO_vfprintf+0x3d34)[0x7f5fb5f8d0d4] /lib/libc.so.6(__vsprintf_chk+0x99)[0x7f5fb60415d9] /lib/libc.so.6(__sprintf_chk+0x7f)[0x7f5fb604151f] r.sunmask(main+0x1723)[0x403943] /lib/libc.so.6(__libc_start_main+0xfd)[0x7f5fb5f62c4d] r.sunmask[0x401e29] === Memory map: 0040-00407000 r-xp 41:01 58216 /usr/lib/grass64/bin/r.sunmask 00606000-00607000 r--p 6000 41:01 58216 /usr/lib/grass64/bin/r.sunmask 00607000-00608000 rw-p 7000 41:01 58216 /usr/lib/grass64/bin/r.sunmask 012cd000-026f8000 rw-p 00:00 0 [heap] 7f5fad10d000-7f5fad119000 r-xp 41:01 31707 /lib/libnss_files-2.11.1.so 7f5fad119000-7f5fad318000 ---p c000 41:01 31707 /lib/libnss_files-2.11.1.so 7f5fad318000-7f5fad319000 r--p b000 41:01 31707 /lib/libnss_files-2.11.1.so 7f5fad319000-7f5fad31a000 rw-p c000 41:01 31707 /lib/libnss_files-2.11.1.so 7f5fad31a000-7f5fad324000 r-xp 41:01 11268 /lib/libnss_nis-2.11.1.so 7f5fad324000-7f5fad523000 ---p a000 41:01 11268 /lib/libnss_nis-2.11.1.so 7f5fad523000-7f5fad524000 r--p 9000 41:01 11268 /lib/libnss_nis-2.11.1.so 7f5fad524000-7f5fad525000 rw-p a000 41:01 11268 /lib/libnss_nis-2.11.1.so 7f5fad525000-7f5fad52d000 r-xp 41:01 11247 /lib/libnss_compat-2.11.1.so 7f5fad52d000-7f5fad72c000 ---p 8000 41:01 11247 /lib/libnss_compat-2.11.1.so 7f5fad72c000-7f5fad72d000 r--p 7000 41:01 11247 /lib/libnss_compat-2.11.1.so 7f5fad72d000-7f5fad72e000 rw-p 8000 41:01 11247 /lib/libnss_compat-2.11.1.so 7f5fad72e000-7f5fad731000 r-xp 41:01 35673 /lib/libgpg-error.so.0.4.0 7f5fad731000-7f5fad93 ---p 3000 41:01 35673 /lib/libgpg-error.so.0.4.0 7f5fad93-7f5fad931000 r--p 2000 41:01 35673 /lib/libgpg-error.so.0.4.0 7f5fad931000-7f5fad932000 rw-p 3000 41:01 35673 /lib/libgpg-error.so.0.4.0 7f5fad932000-7f5fad942000 r-xp 41:01 54602 /usr/lib/libtasn1.so.3.1.7 7f5fad942000-7f5fadb41000 ---p 0001 41:01 54602 /usr/lib/libtasn1.so.3.1.7 7f5fadb41000-7f5fadb42000 r--p f000 41:01 54602 /usr/lib/libtasn1.so.3.1.7 7f5fadb42000-7f5fadb43000 rw-p 0001 41:01 54602 /usr/lib/libtasn1.so.3.1.7 7f5fadb43000-7f5fadb5c000 r-xp 41:01 31701 /usr/lib/libsasl2.so.2.0.23 7f5fadb5c000-7f5fadd5b000 ---p 00019000 41:01 31701 /usr/lib/libsasl2.so.2.0.23 7f5fadd5b000-7f5fadd5c000 r--p 00018000 41:01 31701 /usr/lib/libsasl2.so.2.0.23 7f5fadd5c000-7f5fadd5d000 rw-p 00019000 41:01 31701 /usr/lib/libsasl2.so.2.0.23 7f5fadd5d000-7f5fadd73000 r-xp 41:01 10299 /lib/libresolv-2.11.1.so 7f5fadd73000-7f5fadf72000 ---p 00016000 41:01 10299 /lib/libresolv-2.11.1.so 7f5fadf72000-7f5fadf73000 r--p 00015000 41:01 10299 /lib/libresolv-2.11.1.so 7f5fadf73000-7f5fadf74000 rw-p 00016000 41:01 10299 /lib/libresolv-2.11.1.so 7f5fadf74000-7f5fadf76000 rw-p 00:00 0 7f5fadf76000-7f5fadf78000 r-xp 41:01 35463 /lib/libkeyutils-1.2.so 7f5fadf78000-7f5fae177000 ---p 2000 41:01 35463 /lib/libkeyutils-1.2.so 7f5fae177000-7f5fae178000 r--p 1000 41:01 35463 /lib/libkeyutils-1.2.so 7f5fae178000-7f5fae179000 rw-p 2000 41:01 35463 /lib/libkeyutils-1.2.so 7f5fae179000-7f5fae18 r-xp 41:01 39553 /usr/lib/libkrb5support.so.0.1 7f5fae18-7f5fae37f000 ---p 7000 41:01 39553 /usr/lib/libkrb5support.so.0.1
[GRASS-user] NVIZ Legend
I would like to place a legend on my map of the volume. It seems like it would be pretty straight forward, but when I click on Place legend and on the map to set the corners, nothing happens. Thanks, Suzanne ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user
Re: [GRASS-user] pb. with netCDF row order
Hi Eduardo, I have downloaded your file and indeed as you guessed there is a way to select the time index, and possibly also a level (altitude or depth) index. It goes through optional positional arguments which are not documented (sorry), because one has to guess that 'l' stands for the time index and 'k' for the level one: bash nc2grass.sh -h Usage: nc2grass.sh [-h] nc2grass.sh [-x axis name] [-y axis name] [-z axis name] [-t axis name] [-m missing value] netCDF file variable imin imax jmin jmax [l [k]] -h: help -x: axis name in input file. Default: longitude -y: axis name in input file. Default: latitude -z: axis name in input file. Default: z -t: axis name in input file. Default: time -m: missing value code in output header. Default: -9.99e+02 Actually in your case 'ncdump -h' shows that the missing value flag is 1.e+30f and you can tell GRASS about it using the -m option; my experience is that you have to provide this flag with the very same formatting given to awk in the script, that is +1.00e+30 (check out the default value). To get the first time index in your file: nc2grass.sh -m +1.00e+30 t2m.mean.KNMI.HA2.nc t2m 1 100 1 80 1 \ t2m_l1.txt latN latS lonE lonW: 74.750 35.250 34.750 -14.750 Or you can automate the extraction like this: bash for l in 1 2 3 4; do nc2grass.sh -m +1.00e+30 t2m.mean.KNMI.HA2.nc t2m 1 100 1 80 $l \ t2m_l$l.txt done latN latS lonE lonW: 74.750 35.250 34.750 -14.750 latN latS lonE lonW: 74.750 35.250 34.750 -14.750 latN latS lonE lonW: 74.750 35.250 34.750 -14.750 latN latS lonE lonW: 74.750 35.250 34.750 -14.750 bash ls t2m_l1.txt t2m_l2.txt t2m_l3.txt t2m_l4.txt t2m.mean.KNMI.HA2.nc One potential shortcoming of the script though is that you may provide a time index, or a time index and a level index, but not a level index alone... a fix could be to provide 'k' and 'l' as options instead of positional arguments. Hope it helps. Le mardi 26 octobre 2010 à 12:48 +0200, Eduardo Corbelle Rico a écrit : Nicolas, I've been struggling with the issue of row order in netCDF files and your post came perfect for me. Thank you very much for it. I still have a problem that surely you or anyone in the list would find trivial: the file I'm trying to convert (downloadable in the Prudence project: http://prudence.dmi.dk/data/seasonal/KNMI/t2m.mean.KNMI.HA2.nc.gz ) has four time bands, which I can't write separately into different ascii files. I'm using the script as... ./nc2grass-0001.bin t2m.mean.KNMI.HA2.nc t2m 1 100 1 80 t2m.txt ...and the four time (seasonal) bands came together in the same ascii line. Should I use any additional argument with the script to be able to get four separate ascii files? Thanks a lot! ___ grass-user mailing list grass-user@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-user