[GRASS-user] r.in.gdal global raster incorrect extents

Jamie Adams jaadfoo at gmail.com
Mon Oct 13 19:59:51 EDT 2008


Sure, python w/ gdal is great for doing these sanity checks.  Assuming you
are using a FWTools install or have the python-gdal plugin:

python

>>> import gdal

or newer version:
>>> from osgeo import gdal

>>> image = gdal.Open('/the/path/to/my/raster.tif',gdal.GA_ReadOnly)

****or if your version of gdal has Grass support ****
>>> image =
gdal.Open('/grassdir/location/mapset/cellhd/rastername',gdal.GA_ReadOnly)

>>> image.GetGeoTransform()
(-180.0, 0.0083333333333333332, 0.0, 90.0, 0.0, -0.0083333333333333332)

In my case, the source GeoTiff had a geotransform of:
(-180.00000000012497, 0.0083333333333333297, 0.0, 90.0, 0.0,
-0.0083333333333333297)

One strange thing was, the original grass import (west coordinate of 180E)
had the same geotransform as the corrected raster I ran r.region on.
According to gdal, they were the same.

Looks like I need to file a bug report.

Enjoy.

-Jamie

On Mon, Oct 13, 2008 at 4:18 PM, Nikos Alexandris <
nikos.alexandris at felis.uni-freiburg.de> wrote:

> On Mon, 2008-10-13 at 16:13 -0700, Jamie Adams wrote:
> > Thanks for the suggestions.  I opened the image up in python using
> > gdal, looked at the geotransform and found that the image is
> > ever-so-slightly shifted west (-180.00000000012497).  Hence the
> > negative W-E center.  Maybe this is why GRASS thinks it has a 180E
> > origin also, though I don't know.
> >
> > I checked the region - same problem - then set it manually and
> > re-imported.  Same results.  In the end I was able to assign correct
> > extents using r.region.  Though the boundary isn't exactly at 180W, I
> > think nine 0s after the decimal point is a bit much.  :-)
> >
> > Thanks again.
> >
> > -Jamie
>
> Jamie,
>
> would you share some python command examples (using gdal)? I am learning
> python stuff (although very slowly) and I would like to have some
> examples as the one you did.
>
> Thank you, Nikos
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20081013/e291527e/attachment-0001.html


More information about the grass-user mailing list