[gdal-dev] Copy only georeference between two images

Giacomo Piva piva at meeo.it
Tue Sep 14 05:55:49 EDT 2010


I think that you want to work in this way:
You can "copy" the georeference from an already opened dataset 
(inputhDataset) ...

         pszTargetSRS = (char *)GDALGetProjectionRef(inputhDataset);
         GDALGetGeoTransform(inputhDataset, padfGeoTransform);
         nGCPCount = GDALGetGCPCount(inputhDataset);

         if(nGCPCount != 0){
             pasGCPList = GDALGetGCPs(inputhDataset);
             pszGCPProjection = GDALGetGCPProjection(inputhDataset);
         }

Then, you can "paste" the georeference information to the output dataset 
(outputhDataset) in this way:

         GDALSetProjection(outputhDataset, pszTargetSRS);
         GDALSetGeoTransform(outputhDataset, padfGeoTransform);

         if (nGCPCount != 0)
             
GDALSetGCPs(outputhDataset,nGCPCount,pasGCPList,pszGCPProjection);

where the used variables are:

     GDALDatasetH outputhDataset;
     GDALDatasetH inputhDataset;

     const GDAL_GCP *pasGCPList;
     const char *pszGCPProjection;
     int nGCPCount;
     double padfGeoTransform[6];
     char *pszTargetSRS;

On 09/13/2010 04:45 PM, canduc17 wrote:
> One simple question:
>
> I have two identical images, exept for their their georeferentiation. They
> represent the same scene, their sizes are identical, but one of them has a
> correct UTM georeferentiation and the second one hasn't.
>
> In which way can I copy and paste the correct georeferentiation from one to
> another?
>
> Thanks in advance.
>    


-- 
Giacomo Piva

MEEO S.r.l.
Via Saragat 9
I-44122 Ferrara, Italy
Tel: +39 0532 1861501
Fax: +39 0532 1861637
http://www.meeo.it

========================================
"ATTENZIONE:le informazioni contenute in questo messaggio sono
da considerarsi confidenziali ed il loro utilizzo è riservato unicamente
al destinatario sopra indicato. Chi dovesse ricevere questo messaggio
per errore è tenuto ad informare il mittente ed a rimuoverlo
definitivamente da ogni supporto elettronico o cartaceo."

"WARNING:This message contains confidential and/or proprietary
information which may be subject to privilege or immunity and which
is intended for use of its addressee only. Should you receive this
message in error, you are kindly requested to inform the sender and
to definitively remove it from any paper or electronic format."



More information about the gdal-dev mailing list