Pietro wrote: > > Why the ctypes version return 'PERMANENT' instead of 'user1'?
Glynn Clements wrote: > The $GISRC file is read the first time that an environment lookup is > made. There is no way to force it to be re-read. This means that I can't use instructions like # retrieve existing Spectral bands landsat_elements['Spectral Bands'] = \ Mapset().glist('rast', pattern = 'B[123457]') # alternative naming... if not landsat_elements['Spectral Bands']: landsat_elements['Spectral Bands'] = \ Mapset().glist('rast', pattern = 'B[123457]0') # no results? if not landsat_elements['Spectral Bands']: print "No Spectral bands named after a B? or B?0 pattern found!" in a function (pasted below) which I call from within a "for" loop to go through Mapsets that potentially contain raster maps named differently? I need to use another way to feed raster maps in a dictionary, right? I need to change the way raster maps are fed in a dictionary, i.e. use something like data['Spectral Bands'] = list(zip(*grass.mlist_pairs('rast', 'B[123457]')) [0]) ? And then, what will be the role of pygrass' Mapset() function? Thank you (Pietro & Glyyn), Nikos The following function is called from within a for loop over different Mapsets: ############################################################################# # List & Resolution of Landsat Rasters, Controllers for expected names ====== def retrieve_landsat_rasters(verbose = False): landsat_elements = dict() # retrieve existing Spectral bands -------------------------------------- landsat_elements['Spectral Bands'] = \ Mapset().glist('rast', pattern = 'B[123457]') # alternative naming... if not landsat_elements['Spectral Bands']: landsat_elements['Spectral Bands'] = \ Mapset().glist('rast', pattern = 'B[123457]0') # no results? if not landsat_elements['Spectral Bands']: print "No Spectral bands named after a B? or B?0 pattern found!" # resolution of Spectral bands landsat_elements['Resolution Spectral'] = \ int(grass.raster_info(landsat_elements['Spectral Bands'][0])['nsres']) # retrieve existing Temperature channels -------------------------------- landsat_elements['Temperature Channels'] = \ Mapset().glist('rast', pattern = 'B6[12]') # no results? if not landsat_elements['Temperature Channels']: print "There are no Landsat Temperature channels named B61, B62!" # temperature channels (resolution = 30 or 60m) landsat_elements['Resolution Temperature'] = \ int(grass.raster_info(landsat_elements['Temperature Channels'][0]) ['nsres']) # retrieve existing Panchromatic channels ------------------------------- landsat_elements['Panchromatic Channel'] = \ Mapset().glist('rast', pattern = 'B8') # alternative naming if not landsat_elements['Panchromatic Channel']: landsat_elements['Panchromatic Channel'] = \ Mapset().glist('rast', pattern = 'B80') # no results? if not landsat_elements['Panchromatic Channel']: print "There is no Landsat Panchromatic channel named B8 or B80!" # panchromatic channels (resolution = 15m) landsat_elements['Resolution Panchromatic'] = \ int(grass.raster_info(landsat_elements['Panchromatic Channel'])['nsres']) if verbose: for key in sorted(landsat_elements.keys()): print "%s: %r" % (key, landsat_elements[key]) return landsat_elements ############################################################################# _______________________________________________ grass-dev mailing list grass-dev@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/grass-dev