[GRASS-user] i.rectify: how to make it works?!?!?

Hello!
I’m trying to use imagery tools to georeference/rectify an image taken from google earth…
Here’s the procedure I’ve used without success:

  • From GEarth saved image to a local file (jpeg) ( I’ve tried to convert this jpeg to png but this didn’t helped me. In both case I’ve keeped the image as 24 bit…)
  • Created a location wgs84 utm29 (North!) with region coordinate taken from GEarth (in local format)
  • Created a location xy in grass (6.2.3) with region as big as the picture
  • Imported the image with g.in.gdal: this creates 3 raster maps, blue green and red
  • r.composite the 3 rasters to one “gearth” raster
  • i.group to create group “group” containing the gearth raster
  • i.target giving target the wgs84 utm29 location (mapset user)
  • i.points to give 3 GCPs
    (- tried also to run i.group to remove the gearth raster from r.composite and add the 3 rgb rasters map)
  • i.rectify -a group=group input=group extension=_rect order=1

Everything goes fine till here, except for the fact that if I add the -c option to i.rectify it will always fail with “error while writing to temp file”.
However, when I go to other location the map doesn’t display.
If I’ve rectified the 3 rgb rasters I can try to display the map with an RGB layer or creating a single raster map with r.composite but, first of all, it takes forever (running “top” while doing this displayed a 99% of CPU use by d.rgb or r.composite) and, last but not last, the map doesn’t display. If I select on the map display “zoom to selected map” it will zoom to default region (the selected region in this location) even if I used i.rectify without the -c flag!
Worster if I try to rectify the "r.composite"d raster (the one containing the 3 imported channel) first and then rectify it. Everything goes ok but if I try to display it grass just stuck and I need to restart the x server to quit the grass windows…

I had a look at the data in the wgs84_utm29 location and noticed that this last "r.composite"d raster hasn’t been “converted”. Data in the cell directory is around 24 kb and there is a 148 kb file in the cell_misc/$RASTER_NAME directory … starting jpeg was a couple of MBs…
Stranger in the other case (rectifying the 3 channels and then displaying rgb layer or r.composite them): the files in the cell directory are around 15 kb and 148 kb in the cell_misc folders, but after r.composite, the raster coming from this has 6.9 MB in the cell folder and 107.3 MB in the cell_misc folder of data.
All the files I’m talking about in the cell misc folder are called “null” and dolphin recognized them by the MIME type as jpeg2000, but gwenview isn’t able to display them…

My configuration is the installation of the GRASS Live DVD coming from the Trento University in a VMWare machine running with VMPlayer 2.0.5 on Debian Etch.
This live should be Kubuntu Hardy ( ?) based.

Enrico Graziani wrote:

Hello!
I'm trying to use imagery tools to georeference/rectify an image taken from google earth...
Here's the procedure I've used without success:
- From GEarth saved image to a local file (jpeg) ( I've tried to convert this jpeg to png but this didn't helped me. In both case I've keeped the image as 24 bit...)
- Created a location wgs84 utm29 (North!) with region coordinate taken from GEarth (in local format)
- Created a location xy in grass (6.2.3) with region as big as the picture
- Imported the image with g.in.gdal: this creates 3 raster maps, blue green and red
- r.composite the 3 rasters to one "gearth" raster
- i.group to create group "group" containing the gearth raster
- i.target giving target the wgs84 utm29 location (mapset user)
- i.points to give 3 GCPs
(- tried also to run i.group to remove the gearth raster from r.composite and add the 3 rgb rasters map)
- i.rectify -a group=group input=group extension=_rect order=1
Everything goes fine till here, except for the fact that if I add the -c option to i.rectify it will always fail with "error while writing to temp file".
However, when I go to other location the map doesn't display.
If I've rectified the 3 rgb rasters I can try to display the map with an RGB layer or creating a single raster map with r.composite but, first of all, it takes forever (running "top" while doing this displayed a 99% of CPU use by d.rgb or r.composite) and, last but not last, the map doesn't display. If I select on the map display "zoom to selected map" it will zoom to default region (the selected region in this location) even if I used i.rectify without the -c flag!
Worster if I try to rectify the "r.composite"d raster (the one containing the 3 imported channel) first and then rectify it. Everything goes ok but if I try to display it grass just stuck and I need to restart the x server to quit the grass windows...
I had a look at the data in the wgs84_utm29 location and noticed that this last "r.composite"d raster hasn't been "converted". Data in the cell directory is around 24 kb and there is a 148 kb file in the cell_misc/$RASTER_NAME directory .. starting jpeg was a couple of MBs..
Stranger in the other case (rectifying the 3 channels and then displaying rgb layer or r.composite them): the files in the cell directory are around 15 kb and 148 kb in the cell_misc folders, but after r.composite, the raster coming from this has 6.9 MB in the cell folder and 107.3 MB in the cell_misc folder of data.
All the files I'm talking about in the cell misc folder are called "null" and dolphin recognized them by the MIME type as jpeg2000, but gwenview isn't able to display them...
My configuration is the installation of the GRASS Live DVD coming from the Trento University in a VMWare machine running with VMPlayer 2.0.5 on Debian Etch.
This live should be Kubuntu Hardy ( ?) based.
------------------------------------------------------------------------

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user
  

For a quick georeferencing, with just 3 gcps, you can just use gdal.

gdal_translate -a_srs "EPSG:4326" -of GTiff -gcp x1 y1 X1 Y1 -gcp x2 y2 X2 Y2 -gcp x3 y3 X3 Y3 gearth.jpg gearth.tif

gdalwarp -t_srs "EPSG:4326" -rc gearth.tif gearth_rectified.tif

Then load the image with r.in.gdal.
You can get the gcps by hovering the mouse over landmarks in The Gimp (x,y) and Google Earth (X,Y).
You can find the EPSG code for your utm region here: http://www.epsg-registry.org/

Cheers

John

--

Dr John Stevenson
Postdoctoral Research Associate
School of Earth, Atmospheric and Environmental Sciences
Williamson Building (Room 2.42)
University of Manchester
Manchester M13 9PL, UK
tel. +44(0)161 306 6585; fax. +44(0)161 306 9361;
john.stevenson@manchester.ac.uk

Thank you John for the answer.
That's a choiche (I will try it after lunch time) but I'm studying a
more user friendly approach as I'm looking to find a collection of
tools to use in our monkey... sorry, office environment....
(So basically now I'm focused on GRASS while later maybe I'll try
QGIS et similia to find out something more "usable")

--------------------------------------------------
From: "John Stevenson" <john.stevenson@manchester.ac.uk>
Sent: Tuesday, April 07, 2009 1:26 PM
To: "Enrico Graziani" <mrenrich84@gmail.com>
Cc: <grass-user@lists.osgeo.org>
Subject: Re: [GRASS-user] i.rectify: how to make it works?!?!?

Enrico Graziani wrote:

Hello!
I'm trying to use imagery tools to georeference/rectify an image taken
from google earth...
Here's the procedure I've used without success:
- From GEarth saved image to a local file (jpeg) ( I've tried to convert
this jpeg to png but this didn't helped me. In both case I've keeped the
image as 24 bit...)
- Created a location wgs84 utm29 (North!) with region coordinate taken
from GEarth (in local format)
- Created a location xy in grass (6.2.3) with region as big as the
picture
- Imported the image with g.in.gdal: this creates 3 raster maps, blue
green and red
- r.composite the 3 rasters to one "gearth" raster
- i.group to create group "group" containing the gearth raster
- i.target giving target the wgs84 utm29 location (mapset user)
- i.points to give 3 GCPs
(- tried also to run i.group to remove the gearth raster from r.composite
and add the 3 rgb rasters map)
- i.rectify -a group=group input=group extension=_rect order=1
Everything goes fine till here, except for the fact that if I add the -c
option to i.rectify it will always fail with "error while writing to temp
file".
However, when I go to other location the map doesn't display.
If I've rectified the 3 rgb rasters I can try to display the map with an
RGB layer or creating a single raster map with r.composite but, first of
all, it takes forever (running "top" while doing this displayed a 99% of CPU
use by d.rgb or r.composite) and, last but not last, the map doesn't
display. If I select on the map display "zoom to selected map" it will zoom
to default region (the selected region in this location) even if I used
i.rectify without the -c flag!
Worster if I try to rectify the "r.composite"d raster (the one containing
the 3 imported channel) first and then rectify it. Everything goes ok but
if I try to display it grass just stuck and I need to restart the x server
to quit the grass windows...
I had a look at the data in the wgs84_utm29 location and noticed that
this last "r.composite"d raster hasn't been "converted". Data in the cell
directory is around 24 kb and there is a 148 kb file in the
cell_misc/$RASTER_NAME directory .. starting jpeg was a couple of MBs..
Stranger in the other case (rectifying the 3 channels and then displaying
rgb layer or r.composite them): the files in the cell directory are around
15 kb and 148 kb in the cell_misc folders, but after r.composite, the raster
coming from this has 6.9 MB in the cell folder and 107.3 MB in the cell_misc
folder of data.
All the files I'm talking about in the cell misc folder are called "null"
and dolphin recognized them by the MIME type as jpeg2000, but gwenview isn't
able to display them...
My configuration is the installation of the GRASS Live DVD coming from
the Trento University in a VMWare machine running with VMPlayer 2.0.5 on
Debian Etch.
This live should be Kubuntu Hardy ( ?) based.
------------------------------------------------------------------------

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

For a quick georeferencing, with just 3 gcps, you can just use gdal.

gdal_translate -a_srs "EPSG:4326" -of GTiff -gcp x1 y1 X1 Y1 -gcp x2 y2 X2
Y2 -gcp x3 y3 X3 Y3 gearth.jpg gearth.tif

gdalwarp -t_srs "EPSG:4326" -rc gearth.tif gearth_rectified.tif

Then load the image with r.in.gdal.
You can get the gcps by hovering the mouse over landmarks in The Gimp
(x,y) and Google Earth (X,Y).
You can find the EPSG code for your utm region here:
http://www.epsg-registry.org/

Cheers

John

--

Dr John Stevenson
Postdoctoral Research Associate
School of Earth, Atmospheric and Environmental Sciences
Williamson Building (Room 2.42)
University of Manchester
Manchester M13 9PL, UK
tel. +44(0)161 306 6585; fax. +44(0)161 306 9361;
john.stevenson@manchester.ac.uk

The problem was that the 3 GCP are diagonal to the image (bottom-left
to top-right). Giving other 2-3 points on the others vertex made it
works.