[GRASS-dev] [GRASS-SVN] r57127 - in grass/trunk/scripts: . g.isis3mt

Martin Landa landa.martin at gmail.com
Sun Jul 14 15:37:44 PDT 2013


Hi Yann,

don't know, but probably addons would be probably better place for
this module rather then trunk.

Martin


2013/7/14  <svn_grass at osgeo.org>:
> Author: ychemin
> Date: 2013-07-14 09:56:43 -0700 (Sun, 14 Jul 2013)
> New Revision: 57127
>
> Added:
>    grass/trunk/scripts/g.isis3mt/
>    grass/trunk/scripts/g.isis3mt/Makefile
>    grass/trunk/scripts/g.isis3mt/g.isis3mt.html
>    grass/trunk/scripts/g.isis3mt/g.isis3mt.py
> Modified:
>    grass/trunk/scripts/Makefile
> Log:
> Generate an ISIS3 map template from actual location
>
> Modified: grass/trunk/scripts/Makefile
> ===================================================================
> --- grass/trunk/scripts/Makefile        2013-07-14 16:45:55 UTC (rev 57126)
> +++ grass/trunk/scripts/Makefile        2013-07-14 16:56:43 UTC (rev 57127)
> @@ -15,6 +15,7 @@
>         db.test \
>         g.extension \
>         g.extension.rebuild.all \
> +       g.isis3mt \
>         g.manual \
>         i.image.mosaic \
>         i.in.spotvgt \
>
> Added: grass/trunk/scripts/g.isis3mt/Makefile
> ===================================================================
> --- grass/trunk/scripts/g.isis3mt/Makefile                              (rev 0)
> +++ grass/trunk/scripts/g.isis3mt/Makefile      2013-07-14 16:56:43 UTC (rev 57127)
> @@ -0,0 +1,7 @@
> +MODULE_TOPDIR = ../..
> +
> +PGM=g.isis3mt
> +
> +include $(MODULE_TOPDIR)/include/Make/Script.make
> +
> +default: script
>
>
> Property changes on: grass/trunk/scripts/g.isis3mt/Makefile
> ___________________________________________________________________
> Added: svn:mime-type
>    + text/x-makefile
> Added: svn:eol-style
>    + native
>
> Added: grass/trunk/scripts/g.isis3mt/g.isis3mt.html
> ===================================================================
> --- grass/trunk/scripts/g.isis3mt/g.isis3mt.html                                (rev 0)
> +++ grass/trunk/scripts/g.isis3mt/g.isis3mt.html        2013-07-14 16:56:43 UTC (rev 57127)
> @@ -0,0 +1,15 @@
> +<h2>DESCRIPTION</h2>
> +
> +<em>g.isis3mt</em> Generates an ISIS3 map template file according to the
> + current GRASS projection parameters
> +
> +<h2>NOTE</h2>
> +
> +The ISIS3 user should use  matchmap=yes in cam2map
> +
> +<h2>AUTHOR</h2>
> +
> +Alessandro Frigeri, INA, Ispra, Italy
> +Added to GRASS 7 by Yann Chemin
> +
> +<p><i>Last changed: $Date$</i>
>
>
> Property changes on: grass/trunk/scripts/g.isis3mt/g.isis3mt.html
> ___________________________________________________________________
> Added: svn:mime-type
>    + text/html
> Added: svn:keywords
>    + Author Date Id
> Added: svn:eol-style
>    + native
>
> Added: grass/trunk/scripts/g.isis3mt/g.isis3mt.py
> ===================================================================
> --- grass/trunk/scripts/g.isis3mt/g.isis3mt.py                          (rev 0)
> +++ grass/trunk/scripts/g.isis3mt/g.isis3mt.py  2013-07-14 16:56:43 UTC (rev 57127)
> @@ -0,0 +1,158 @@
> +#!/usr/bin/env python
> +#
> +############################################################################
> +#
> +# MODULE:      g.isis3mt
> +# AUTHOR(S):   Alessandro Frigeri;
> +# PURPOSE:     Generates an ISIS3 map template file according to the current
> +#              GRASS projection parameters
> +# COPYRIGHT:   (C) 2009,2010 by Alessandro Frigeri for the GRASS Development Team
> +#
> +#              This program is free software under the GNU General Public
> +#              License (>=v2). Read the file COPYING that comes with GRASS
> +#              for details.
> +# HISTORY:     Apr 15th, 2010: Time for the first public release
> +#              Sep 15th, 2010: added LatLon Range and mpp/ppd resolution
> +#                              options
> +#
> +#############################################################################
> +
> +# TODO
> +#  Add a note to the user to use  matchmap=yes in cam2map
> +
> +#%module
> +#%  description: Generates an ISIS3 map template file according to the current GRASS coordinate reference system
> +#%  keywords: generic, projection
> +#%end
> +
> +#%option
> +#% key: body
> +#% type: string
> +#% description: Target planetary body
> +#% options: MOON,MERCURY,VENUS,MARS,Phobos,Deimos,JUPITER,Amalthea,Io,Europa,Ganymede,Callisto,SATURN,Janus,Epimetheus,Mimas,Enceladus,Tethys,Dione,Rhea,Titan,Hyperion,Iapetus,URANUS,Miranda,Ariel,Umbriel,Titania,Oberon,NEPTUNE
> +#% required : yes
> +#%end
> +
> +#%option
> +#% key: out
> +#% type: string
> +#% gisprompt: new_file,file,output
> +#% description: Filename for the ISIS3 maptemplate to be generated
> +#% required : yes
> +#%end
> +
> +#%option
> +#% key: outres
> +#% type: double
> +#% description: Resolution of the ISIS3 projected data (default is: camera resolution)
> +#% required : no
> +#%end
> +
> +#%Option
> +#% key: restype
> +#% type: string
> +#% required: no
> +#% multiple: no
> +#% options: mpp,ppd
> +#% description: Resolution type: meters per pixel (mpp) or pixels per degree (ppd)
> +#% answer: mpp
> +#%End
> +
> +#%flag
> +#% key: a
> +#% description: Align ISIS3 data to the extents of the current GRASS region
> +#%end
> +
> +import subprocess,sys,os,platform
> +import grass.script as grass
> +from grass.lib import gis as grasslib
> +from grass.lib import proj as grassproj
> +from UserDict import *
> +import re,string
> +
> +if "GISBASE" not in os.environ:
> +    print "You must be in GRASS GIS to run this program."
> +    sys.exit(1)
> +
> +# initialize
> +grasslib.G_gisinit('')
> +
> +
> +projdict = {'sinu':'Sinusoidal',
> +            'merc':'Mercator',
> +            'tmerc':'TransverseMercator',
> +            'ortho':'Orthographic',
> +            'stere':'PolarStereographic',
> +            'cc':'SimpleCylindrical',
> +            'eqc':'Equirectangular',
> +            'lcc':'LambertConformal'
> +           }
> +
> +paradict = {'proj' :'ProjectionName',         # Name of the projection
> +            'lon_0':'CenterLongitude',        # Center Longitude
> +            'lat_0':'CenterLatitude',         # Center Latitude
> +            'k':'ScaleFactor',                # Scale Factor
> +            'lat_1':'FirstStandardParallel',  # First standard parallel
> +            'lat_2':'SecondStandardParallel', # Second standard parallel
> +            'a':'EquatorialRadius',           # semi major axis
> +            'b':'PolarRadius',                # semi minor axis
> +            'to_meter':None,                  # no map on isis3
> +            'y_0':None,                      # false northing
> +            'x_0':None,                       # false easting
> +           }
> +
> +class IsisMapTemplate(IterableUserDict):
> +   def __init__(self,isisdict):
> +      UserDict.__init__(self)
> +      if isisdict is not None:
> +          UserDict.__init__(self,isisdict)
> +      self['LatitudeType'] = 'Planetographic'
> +      self['LongitudeDirection'] = 'PositiveEast'
> +      self['LongitudeDomain'] = '180'
> +
> +   def dump(self,out):
> +       out.write("Group = Mapping\n")
> +       keys = self.keys()
> +       for k in self.keys():
> +           if k != None:
> +              myk = string.rjust(k, 30)
> +              myv = string.ljust(self[k], 20)
> +              out.write("%s = %s\n"%(myk,myv))
> +       out.write("End_Group\nEnd")
> +
> +
> +def main():
> +    isis3 = {}
> +    outfile = options['out']
> +    body = options['body']
> +    pj = grasslib.G_get_projinfo()
> +    if options['outres'] and options['restype']=='mpp' : isis3['PixelResolution'] = "%f <meters>"%float(options['outres'])
> +    if options['outres'] and options['restype']=='ppd' : isis3['Scale'] = "%f <pixel/degree>"%float(options['outres'])
> +    isis3['TargetName'] = body
> +    if flags['a']:
> +        ret = grass.start_command("g.region", flags="gl", stdout = subprocess.PIPE)
> +        exec(ret.communicate()[0])
> +        isis3['MinimumLatitude'] = "%f"%min(se_lat,sw_lat)
> +        isis3['MaximumLatitude'] = "%f"%max(ne_lat,nw_lat)
> +        isis3['MinimumLongitude'] = "%f"%min(sw_long,nw_long)
> +        isis3['MaximumLongitude'] = "%f"%max(se_long,ne_long)
> +
> +    for p in paradict.keys():
> +        if grasslib.G_find_key_value(p, pj):
> +            k = paradict[p]
> +            v = grasslib.G_find_key_value(p, pj)
> +            if p == 'a' or p == 'b': v = v + ' <meters>'
> +            if p == 'proj' and v == 'll': sys.exit("This GRASS location is in LatLong, no cartographic projection is set.\nExiting...")
> +            if p == 'proj':  k,v = 'ProjectionName', projdict[v]
> +            isis3[k] = v
> +    isis3mt =  IsisMapTemplate(isis3)
> +    of = open(outfile,'w')
> +    isis3mt.dump(of)
> +    sys.stderr.write("Done writing %s ISIS3 MapTemplate file\n"%outfile)
> +
> +if __name__ == "__main__":
> +    options, flags = grass.parser()
> +    main()
> +
> +
> +
>
>
> Property changes on: grass/trunk/scripts/g.isis3mt/g.isis3mt.py
> ___________________________________________________________________
> Added: svn:executable
>    + *
> Added: svn:mime-type
>    + text/x-python
> Added: svn:eol-style
>    + native
>
> _______________________________________________
> grass-commit mailing list
> grass-commit at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-commit



-- 
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa


More information about the grass-dev mailing list