[GRASS-dev] [GRASS GIS] #1594: 180 meridian and r.proj
GRASS GIS
trac at osgeo.org
Wed Oct 9 16:50:37 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):
A few mistakes in my previously-posted code; use this instead:
Cheers,
Andy
{{{
#!python
from grass import script as grass
import re
grass.run_command('g.region', save='default')
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=infile,
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=180./shreg[0], ewres=360./shreg[1],
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', nsres=180./shreg[0], ewres=360./shreg[1],
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)
}}}
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/1594#comment:5>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list