[GRASS-dev] [GRASS GIS] #1594: 180 meridian and r.proj

GRASS GIS trac at osgeo.org
Wed Oct 9 16:31:35 PDT 2013


#1594: 180 meridian and r.proj
------------------------------+---------------------------------------------
 Reporter:  awickert          |       Owner:  grass-dev@…              
     Type:  defect            |      Status:  new                      
 Priority:  normal            |   Milestone:                           
Component:  Raster            |     Version:  svn-trunk                
 Keywords:  r.proj, meridian  |    Platform:  Linux                    
      Cpu:  x86-64            |  
------------------------------+---------------------------------------------

Comment(by awickert):

 Here is my current workaround, using r.proj and r.patch:

 {{{
 #!python

 from grass import script as grass
 import re

 inloc = 'GlobalDatabase30as'
 non_decimal = re.compile(r'[^\d.]+') # for my hack-ish solution below
 # "toponow" NEEDS to be added (some other good too):
 basicfiles = ['precip_2000_2004', 'et_2000_2004', 'cellsize_km2',
 'cellsize_meters2', 'zeros', 'toponow']
 for infile in basicfiles:
   print infile
   # Here we make sure we are using the same resolution as the input map.
   # Getting the resolution - there has got to be a much better way to do
 this,
   # but this is the first thing that came to mind
   shreg = grass.parse_command('r.proj', location=inloc,
 input='precip_2000_2004', output='tmp0', overwrite=True,
 flags='g')['n'].split(' ')[-2:]
   for i in range(len(shreg)):
     shreg[i] = int(non_decimal.sub('', (shreg[i])))
   grass.run_command('g.region', nsres=shreg[0]/180., ewres=shreg[1]/360.,
 e='180E')
   grass.run_command('r.proj', location=inloc, input=infile, output='tmp0',
 overwrite=True)
   grass.run_command('g.region', region='default')
   grass.run_command('g.region', sres=shreg[0]/180., ewres=shreg[1]/360.,
 w='180W')
   grass.run_command('r.proj', location=inloc, input=infile, output='tmp1',
 overwrite=True)
   grass.run_command('g.region', region='default')
   grass.run_command('r.patch', input='tmp0,tmp1', output=infile,
 overwrite=True)
 }}}

 Cheers,

 Andy Wickert

-- 
Ticket URL: <http://trac.osgeo.org/grass/ticket/1594#comment:4>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list