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
44       -T     type handles the encoding of constraint information.  type  =  0
45              indicates  that  no  such information is encoded in the img file
46              (used for pre-1995 versions of the gravity data; all more recent
47              files  do  not support this choice) and gets all data.  type > 0
48              indicates that constraint information is encoded (1995 and later
49              (current)  versions  of the img files) so that one may produce a
50              grid file as follows: -T1 gets data values at  all  points,  -T2
51              gets  data  values at constrained points and NaN at interpolated
52              points; -T3 gets 1 at constrained points and 0  at  interpolated
53              points.
54

OPTIONS

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

EXAMPLES

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

SEE ALSO

170       GMT(1), grdproject(1), mapproject(1)
171
172
173
174GMT 4.3.1                         15 May 2008                   IMG2MERCGRD(1)
Impressum