1IMG2MERCGRD(1)               Generic Mapping Tools              IMG2MERCGRD(1)
2
3
4

NAME

6       img2mercgrd - Extract region of img, preserving Mercator, save as grd
7

SYNOPSIS

9       img2mercgrd  imgfile -Ggrdfile -Rwest/east/south/north[r] -Ttype [ -C ]
10       [ -Dminlat/maxlat ] [ -Nnavg ] [ -Sscale ] [ -V ] [ -Wmaxlon ] [ -mmin‐
11       utes ]
12

DESCRIPTION

14       img2mercgrd  reads  an  img  format  file and creates a grid file.  The
15       Spherical Mercator projection of the img file is preserved, so that the
16       region  -R  set  by  the user is modified slightly; the modified region
17       corresponds to the edges of pixels [or groups  of  navg  pixels].   The
18       grid file header is set so that the x and y axis lengths represent dis‐
19       tance from the west and south edges of  the  image,  measured  in  user
20       default  units,  with -Jm1 and the adjusted -R.  By setting the default
21       ELLIPSOID = Sphere, the user can make overlays with the adjusted -R  so
22       that  they match.  See EXAMPLES below.  The adjusted -R is also written
23       in the grdheader remark, so it can be found later.  The -Ttype  selects
24       all  data or only data at constrained pixels, and can be used to create
25       a grid of 1s and 0s indicating constraint locations.  The  output  grid
26       file is pixel registered; it inherits this from the img file.
27
28       imgfile
29              An img format file such as the marine gravity or seafloor topog‐
30              raphy fields estimated from satellite altimeter data by Sandwell
31              and  Smith.   If  the  user  has  set  an  environment  variable
32              $GMT_IMGDIR, then  img2mercgrd  will  try  to  find  imgfile  in
33              $GMT_IMGDIR; else it will try to open imgfile directly.
34
35       -G     grdfile is the name of the output grid file.
36
37       -R     west, east, south, and north specify the Region of interest, and
38              you   may   specify   them   in   decimal    degrees    or    in
39              [+-]dd:mm[:ss.xxx][W|E|S|N]  format.  Append r if lower left and
40              upper right map coordinates are given instead of  w/e/s/n.   The
41              two  shorthands  -Rg  and -Rd stand for global domain (0/360 and
42              -180/+180 in longitude respectively, with -90/+90 in  latitude).
43              Alternatively, specify the name of an existing grid file and the
44              -R settings (and grid spacing, if applicable)  are  copied  from
45              the grid.
46
47       -T     type  handles  the encoding of constraint information.  type = 0
48              indicates that no such information is encoded in  the  img  file
49              (used for pre-1995 versions of the gravity data; all more recent
50              files do not support this choice) and gets all data.  type  >  0
51              indicates that constraint information is encoded (1995 and later
52              (current) versions of the img files) so that one may  produce  a
53              grid  file  as  follows: -T1 gets data values at all points, -T2
54              gets data values at constrained points and NaN  at  interpolated
55              points;  -T3  gets 1 at constrained points and 0 at interpolated
56              points.
57

OPTIONS

59       -C     Set the x and y Mercator coordinates relative to projection cen‐
60              ter (lon = lat = 0) [Default is relative to lower left corner of
61              grid].
62
63       -D     Use the extended latitude range -80.738/+80.738.  Alternatively,
64              append  minlat/maxlat  as  the  latitude extent of the input img
65              file.  [Default is -72.006/72.006].
66
67       -N     Average the values in the input img pixels  into  navg  by  navg
68              squares,  and  create one output pixel for each such square.  If
69              used with -T3 it will report an average constraint between 0 and
70              1.   If  used  with -T2 the output will be average data value or
71              NaN according to whether average constraint is > 0.5.  navg must
72              evenly  divide  into  the  dimensions  of the imgfile in pixels.
73              [Default 1 does no averaging].
74
75       -S     Multiply the img file values by scale  before  storing  in  grid
76              file.   [Default  is  1.0].  (img topo files are stored in (cor‐
77              rected) meters; gravity files in  mGal*10;  vertical  deflection
78              files  in  microradians*10,  vertical  gravity gradient files in
79              Eotvos*10. Use -S0.1 for those files.)
80
81       -V     Selects verbose mode, which will send progress reports to stderr
82              [Default runs "silently"].  Particularly recommended here, as it
83              is helpful to see how the coordinates are adjusted.
84
85       -m     Indicate minutes as the width of an input img pixel  in  minutes
86              of longitude.  [Default is 2.0].
87
88       -W     Indicate maxlon as the maximum longitude extent of the input img
89              file.  Versions since 1995 have had maxlon = 360.0,  while  some
90              earlier files had maxlon = 390.0.  [Default is 360.0].
91

EXAMPLES

93       To extract data in the region -R-40/40/-70/-30 from world_grav.img.7.2,
94       run
95
96       img2mercgrd world_grav.img.7.2 -Gmerc_grav.grd -R-40/40/-70/-30 -T1 -V
97
98       Note that the -V option  tells  us  that  the  range  was  adjusted  to
99       -R-40/40/-70.0004681551/-29.9945810754.    We  can  also use grdinfo to
100       find  that  the   grid   file   header   shows   its   region   to   be
101       -R0/80/0/67.9666667    This  is  the  range  of  x,y we will get from a
102       Spherical             Mercator             projection             using
103       -R-40/40/-70.0004681551/-29.9945810754   and   -Jm1.    Thus,  to  take
104       ship.lonlatgrav and use it to sample the merc_grav.grd, we can do this:
105
106       gmtset ELLIPSOID Sphere
107       mapproject -R-40/40/-70.0004681551/-29.9945810754 -Jm1  ship.lonlatgrav
108       |         grdtrack         -Gmerc_grav.grd         |         mapproject
109       -R-40/40/-70.0004681551/-29.9945810754 -Jm1 -I > ship.lonlatgravsat
110
111       It is recommended to use the above method of projecting and  unproject‐
112       ing  the  data  in  such an application, because then there is only one
113       interpolation step (in grdtrack).  If one first tries  to  convert  the
114       grid  file  to  lon,lat and then sample it, there are two interpolation
115       steps (in conversion and in sampling).
116
117       To make a lon,lat grid from the above grid we can use
118
119       grdproject merc_grav.grd -R-40/40/-70.0004681551/-29.9945810754 -Jm1 -I
120       -F -D2m -Ggrav.grd
121
122       In  some  cases  this  will not be easy as the -R in the two coordinate
123       systems may not align well.  When this happens, we  can  also  use  (in
124       fact, it may be always better to use)
125
126       grd2xyz              merc_grav.grd             |             mapproject
127       -R-40/40/-70.0004681551/-29.994581075 -Jm1 -I | surface -R-40/40/-70/70
128       -I2m -Ggrav.grd
129
130       To  make  a Mercator map of the above region, suppose our .gmtdefaults4
131       MEASURE_UNIT is inch.  Then since the above merc_grav.grd file is  pro‐
132       jected with -Jm1 it is 80 inches wide.  We can make a map 8 inches wide
133       by using -Jx0.1 on any map programs applied to this grid (e.g., grdcon‐
134       tour,  grdimage,  grdview), and then for overlays which work in lon,lat
135       (e.g., psxy, pscoast) we can use the above adjusted -R  and  -Jm0.1  to
136       get the two systems to match up.
137
138       However,  we  can  be  smarter than this.  Realizing that the input img
139       file had pixels 2.0 minutes wide  (or  checking  the  nx  and  ny  with
140       grdinfo merc_grav.grd) we realize that merc_grav.grd used the full res‐
141       olution of the img file and it has 2400 by 2039 pixels, and at 8 inches
142       wide  this  is  300 pixels per inch.  We decide we don't need that many
143       and we will be satisfied with 100 pixels per inch, so we want to  aver‐
144       age  the  data into 3 by 3 squares.  (If we want a contour plot we will
145       probably choose to average the data much more (e.g.  6  by  6)  to  get
146       smooth  contours.)   Since 2039 isn't divisible by 3 we will get a dif‐
147       ferent adjusted OPT(R) this time:
148
149       img2mercgrd world_grav.img.7.2 -Gmerc_grav_2.grd  -R-40/40/-70/-30  -T1
150       -N3 -V
151
152       This      time      we      find     the     adjusted     region     is
153       -R-40/40/-70.023256525/-29.9368261101 and the output is 800 by 601 pix‐
154       els,  a  better size for us.  Now we can create an artificial illumina‐
155       tion file for this using grdgradient:
156
157       grdgradient merc_grav_2.grd -Gillum.grd -A0/270 -Ne0.6
158
159       and if we also have a cpt file called "grav.cpt" we can create a  color
160       shaded relief map like this:
161
162       grdimage merc_grav_2.grd -Iillum.grd -Cgrav.cpt -Jx0.1 -K > map.ps
163       psbasemap  -R-40/40/-70.023256525/-29.9368261101  -Jm0.1  -Ba10  -O  >>
164       map.ps
165
166       Suppose you want to obtain only the constrained data values from an img
167       file,  in  lat/lon  coordinates.   Then  run  img2mercgrd  with the -T2
168       option, use grd2xyz to dump the values, pipe through  grep  -v  NaN  to
169       eliminate NaNs, and pipe through mapproject with the inverse projection
170       as above.
171

SEE ALSO

173       GMT(1), grdproject(1), mapproject(1)
174
175
176
177GMT 4.5.6                         10 Mar 2011                   IMG2MERCGRD(1)
Impressum