[GRASS-user] tiff imported to GRASS loses minus sign in west coordinate

Dear lists,

I need to import the map available here
(http://geodata.grid.unep.ch/mod_download/download_geospatial.php?selectedID=2150&newFile=download/Nightlights_2003_tif.zip)
to GRASS. The map is in Tiff format and appears fine in QGIS, but when
I import it to GRASS (with r.in.gdal) it becomes a very narrow N-S
stripe.

Here's the raster info that QGIS gives me on this map:

- - -
Driver: GTiff/GeoTIFF
Files: /media/disk/MARCIA/dadosExternos/variaveis/UNEP/nightLights/N_Light_2003.tif
       /media/disk/MARCIA/dadosExternos/variaveis/UNEP/nightLights/N_Light_2003.aux
       /media/disk/MARCIA/dadosExternos/variaveis/UNEP/nightLights/N_Light_2003.rrd
Size is 43201, 15601
Coordinate System is:
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0],
    UNIT["degree",0.0174532925199433],
    AUTHORITY["EPSG","4326"]]
Origin = (-180.004166669999989,65.004166670000004)
Pixel Size = (0.008333333300000,-0.008333333300000)
Metadata:
  TIFFTAG_SOFTWARE=IMAGINE TIFF Support
Copyright 1991 - 1999 by ERDAS, Inc. All Rights Reserved
@(#)$RCSfile: etif.c $ $Revision: 1.10.1.9.1.9.2.11 $ $Date:
2004/09/15 18:42:01EDT $
  TIFFTAG_XRESOLUTION=1
  TIFFTAG_YRESOLUTION=1
  TIFFTAG_RESOLUTIONUNIT=1 (unitless)
  AREA_OR_POINT=Area
Image Structure Metadata:
  INTERLEAVE=BAND
Corner Coordinates:
Upper Left (-180.0041667, 65.0041667) (180d 0'15.00"W, 65d 0'15.00"N)
Lower Left (-180.0041667, -65.0041661) (180d 0'15.00"W, 65d 0'15.00"S)
Upper Right ( 180.0041652, 65.0041667) (180d 0'14.99"E, 65d 0'15.00"N)
Lower Right ( 180.0041652, -65.0041661) (180d 0'14.99"E, 65d 0'15.00"S)
Center ( -0.0000007, 0.0000003) ( 0d 0'0.00"W, 0d 0'0.00"N)
Band 1 Block=64x64 Type=Byte, ColorInterp=Gray
  Min=0.000 Max=63.000
  Minimum=0.000, Maximum=63.000, Mean=2.909, StdDev=3.132
  Overviews: 10801x3901, 5401x1951, 2701x976, 1351x488, 676x244, 338x122, 169x61
  Metadata:
    STATISTICS_MINIMUM=0
    STATISTICS_MAXIMUM=63
[...]
- - -

And here's what r.info says about the same map after importing it to GRASS:

- - -
Raster: NLight2003
Rows: 15601
Columns: 43201
N-S resolution: 0.00833333
E-W resolution: 1.92863e-07
North: 65.0042
South: -65.0042
East: 180.004
West: 179.996
Format: integer (0 byte)
Minimum value: 0
Maximum value: 63
Data description: generated by r.in.gdal
Comments: r.in.gdal -o
input="/media/disk/MARCIA/TdadosExternos/variaveis/UNEP/nightLights/N_Light_2003.tif"
output="NLight2003"

- - -

Most of this info looks fine, except the E-W resolution which should
be 0.008333 (like the N-S one), and the west coordinate which should
have a "minus" sign.

I'm using QGIS 1.5 with the GRASS plugin, and tried both under Ubuntu
and Windows. I tried also having someone save it as ASCII and
importing with r.in.arc, but the result was always the same. Any ideas
about what might be causing this? Anyone can manage to import this map
to GRASS correctly?

Thanks for any help,
Márcia

On 10/28/2010 07:56 PM, A. Marcia BARBOSA wrote:

Dear lists,

I need to import the map available here
(http://geodata.grid.unep.ch/mod_download/download_geospatial.php?selectedID=2150&newFile=download/Nightlights_2003_tif.zip)
to GRASS. The map is in Tiff format and appears fine in QGIS, but when
I import it to GRASS (with r.in.gdal) it becomes a very narrow N-S
stripe.

Here's the raster info that QGIS gives me on this map:

I think I know what the problem is. Have a look at the bounds below:

Corner Coordinates:
Upper Left (-180.0041667, 65.0041667) (180d 0'15.00"W, 65d 0'15.00"N)
Lower Left (-180.0041667, -65.0041661) (180d 0'15.00"W, 65d 0'15.00"S)
Upper Right ( 180.0041652, 65.0041667) (180d 0'14.99"E, 65d 0'15.00"N)
Lower Right ( 180.0041652, -65.0041661) (180d 0'14.99"E, 65d 0'15.00"S)
   

The left (W) extent goes beyond -180 and the right (E) also goes beyond +180. So the image has "fallen off the edge" :wink:
If I check with gdalinfo on the original tiff, before importing into GRASS, here's what I see:

micha@hayun-820:~/Download$ gdalinfo Nightlights_2003.tif
Driver: GTiff/GeoTIFF
Size is 43201, 15601
... more lines ...
Pixel Size = (0.008333330042660,-0.008333330042660)
... more metadata ...
Corner Coordinates:
Upper Left (-180.0000000, 65.0000000) (180d 0'0.00"W, 65d 0'0.00"N)
Lower Left (-180.0000000, -65.0082820) (180d 0'0.00"W, 65d 0'29.82"S)
Upper Right ( 180.0081912, 65.0000000) (180d 0'29.49"E, 65d 0'0.00"N)
Lower Right ( 180.0081912, -65.0082820) (180d 0'29.49"E, 65d 0'29.82"S)
Center ( 0.0040956, -0.0041410) ( 0d 0'14.74"E, 0d 0'14.91"S)

Here again the Right side is > 180. So, in import to GRASS, it gets "wrapped" to the west, and the end result is, like above, a very narrow raster with E-W extent 0.0000015 degrees.

One way to work this out is to clip the original raster slightly before importing. The gdal tool gdal_translate does this with the -projwin option like:
gdal_translate -projwin -179.99 65 179.99 -65 Nightlights_2003.tif Nightlights_2003clip.tif

Here, I've shaved off a bit on the E and W so it fits into the -180 to 180 bounds. Now if I redo r.in.gdal using the clipped raster, it appears correctly in GRASS.

--
Micha

Thanks for any help,
Márcia
_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

This mail was received via Mail-SeCure System.

--
Micha Silver
Arava Development Co. +972-52-3665918
http://surfaces.co.il