[gdal-dev] Fastest way to add the GeoTransform to a raster file with Python

Matthieu Rigal rigal at rapideye.de
Fri Sep 19 08:43:31 EDT 2008


Thanks to all the three for your quick responses !

I am getting several infos from the mailing list archives since one year, but 
since I couldn't get more infos about that subject, I decided to also ask a 
question here, and I'm happy to have done that !

My first question was to unprecise, sorry. I forgot to mention that I'm 
working with GTiff palette images.

So, dear Matt, your script does not work, since even in update mode, I am not 
able to set a GeoTransform to it. I get this error:
ERROR 6: SetGeoTransform() is only supported on newly created GeoTIFF files.

From what I understand, there is no other way as to Create, set a 
GeoTransform, and copy the layers.

I will precise what I want to do :
After getting an optimized palette version of original R, G, B GeoTiff 
channels, through transformation with the PIL library, this image became 
pixel/line.

I want to reproject this image to a spherical mercator projection. If I use 
the Create way, there will be one step more.

At the beginning I wanted to modify the source dataset, but there might a way 
to add the GeoTransform "on-the-fly", before the Reprojection... but I 
couldn't find one... I'll accept all suggestions !

Frank, if there is no way  to solve the upper "reflexion", and because you 
mentioned the possible use of the gdal utilities, would you recommend to call 
the utility from within the python script or rather to use the module's 
functions (I'll go for the second one naturally).

Best regards,
Matthieu

On Thursday 18 September 2008 21:06:06 you wrote:
> Will this work?
>
> http://maphew.googlecode.com/svn/trunk/gis/gdal_extras/bin/gdalcopyproj.py
>
>
> matt wilkie
> --------------------------------------------
> Geographic Information,
> Information Management and Technology,
> Yukon Department of Environment
> 10 Burns Road * Whitehorse, Yukon * Y1A 4Y9
> 867-667-8133 Tel * 867-393-7003 Fax
> http://environmentyukon.gov.yk.ca/geomatics/
> --------------------------------------------
>
> Matthieu Rigal wrote:
> > Hi all,
> > Since the method of Create, SetGeoTransform, etc... is "complicated" and
> > unefficient from a performance point of view, what is the way to quickly
> > add the GeoTransform, taken from a referenced raster to a raster that
> > have lost the information.
> >
> > Best regards,
> > Matthieu

On Thursday 18 September 2008 18:09:13 you wrote:
> Matthieu,
>
> I assume the approach that is complicated is to create a
> whole new image with Create(), setting the geotransform on
> that and then copying over all the image data.  is that what
> you mean?
>
> What format of imagery are you working with?  There are
> different limitations on different drivers with regard to updating
> georeferencing "in place".  For for some formats you can just
> open a dataset in update mode, and call SetGeoTransform()
> to update the georeferencing.  For other formats this is not
> possible.
>
> Some formats support world files with various extensions.  For
> these formats the easiest approach might be to just manually
> write out a world file.
>
> From the commandline the easiest way is to use gdal_translate
> and the -a_ullr switch though internally this is of course creating
> a new dataset and copying everything over.
>
> Best regards,


-- 
Matthieu Rigal
Product Development

RapidEye AG			        Tel: +49-(0)3381-89 04 331
Molkenmarkt 30			Fax: +49-(0)3381-89 04 101
14776 Brandenburg/Havel
Germany				        http://www.rapideye.de

RapidEye AG
Molkenmarkt 30
14776 Brandenburg an der Havel
Germany

Head Office/Sitz der Gesellschaft: Brandenburg an der Havel
Management Board/Vorstand: Wolfgang G. Biedermann
Chairman of Supervisory Board/Vorsitzender des Aufsichtsrates: Axel Schmalz
Commercial Register/Handelsregister Potsdam HRB 17 796
Tax Number/Steuernummer: 048/100/00053
VAT-Ident-Number/Ust.-ID: DE 199331235
DIN EN ISO 9001 certified

*************************************************************************
Diese E-Mail enthaelt vertrauliche und/oder rechtlich geschuetzte
Informationen. Wenn Sie nicht der richtige Adressat sind oder diese
E-Mail irrtuemlich erhalten haben, informieren Sie bitte sofort den
Absender und vernichten Sie diese E-Mail. Das unerlaubte Kopieren sowie
die unbefugte Weitergabe dieser E-Mail ist nicht gestattet.

The information in this e-mail is intended for the named recipients
only. It may contain privileged and confidential information. If you
have received this communication in error, any use, copying or
dissemination of its contents is strictly prohibited. Please erase all
copies of the message along with any included attachments and notify
RapidEye AG or the sender immediately by telephone at the number
indicated on this page.


More information about the gdal-dev mailing list