Statistics
| Revision:

svn-gvsig-desktop / tags / v1_1_2_Build_1045 / libraries / libjni-gdal / src-test / CreateCopy.java @ 32257

History | View | Annotate | Download (2.83 KB)

1
/**********************************************************************
2
 * $Id: CreateCopy.java 8765 2006-11-15 00:08:29Z jjdelcerro $
3
 *
4
 * Name:     writetif.java
5
 * Project:  gvSIG - Generalitat Valenciana SIG
6
 * Purpose:  Ejemplo para la prueba del interfaz java de la libreria 
7
 *                         gdal de Frank Warmerdam
8
 * Author:   Nacho Brodin, brodin_ign@gva.es
9
 *
10
 **********************************************************************/
11
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
12
*
13
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
14
*
15
* This program is free software; you can redistribute it and/or
16
* modify it under the terms of the GNU General Public License
17
* as published by the Free Software Foundation; either version 2
18
* of the License, or (at your option) any later version.
19
*
20
* This program is distributed in the hope that it will be useful,
21
* but WITHOUT ANY WARRANTY; without even the implied warranty of
22
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
* GNU General Public License for more details.
24
*
25
* You should have received a copy of the GNU General Public License
26
* along with this program; if not, write to the Free Software
27
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
28
*
29
* For more information, contact:
30
*
31
*  Generalitat Valenciana
32
*   Conselleria d'Infraestructures i Transport
33
*   Av. Blasco Ib??ez, 50
34
*   46010 VALENCIA
35
*   SPAIN
36
*
37
*      +34 963862235
38
*   gvsig@gva.es
39
*      www.gvsig.gva.es
40
*
41
*    or
42
*
43
*   IVER T.I. S.A
44
*   Salamanca 50
45
*   46005 Valencia
46
*   Spain
47
*
48
*   +34 963163400
49
*   dac@iver.es
50
*/
51
import es.gva.cit.jgdal.*;
52
import java.io.*;
53
import java.util.Date;
54
import java.util.StringTokenizer;
55

    
56
public class CreateCopy{
57
        public static void main(String[] args){
58
 
59
          
60
          Gdal migdal=new Gdal();
61
          Gdal dset_dstno=null;
62
        
63
          GdalRasterBand mirasterband=null;
64
          GdalRasterBand rband=null;
65
          int nxsize=0;
66
          int nysize=0;
67
          int rastercount=0;
68
          float total=0;
69
          
70
          
71
          try{
72
            if(args.length==1){
73
                    migdal.open(args[0],Gdal.GA_ReadOnly);
74

    
75
            }else {
76
                    System.out.println("Params: filename"); 
77
                    System.exit(1);
78
            }
79
          }catch(Exception ge){
80
                        ge.printStackTrace();
81
                        //...
82
          }
83

    
84
          
85
          try{
86
                  rastercount=migdal.getRasterCount();
87
            nxsize = migdal.getRasterXSize();
88
            nysize = migdal.getRasterYSize();
89
            System.out.println("N BANDAS="+rastercount+" SIZEX="+nxsize+" SIZEY="+nysize);
90
            System.out.println(migdal.getProjectionRef());        
91
          }catch(GdalException ge){
92
                                                          ge.printStackTrace();
93
                                                          //...
94
                                                     }
95
          
96
          
97
          
98
          try{
99
                          //Obtenemos el driver y creamos el dataset del destino
100

    
101
                          GdalDriver drv=Gdal.getDriverByName("GTiff");
102
                          String[] params={"TILED=YES","PHOTOMETRIC=RGB","TFW=WORLDFILE"};
103
                          drv.createCopy("copia.gif",migdal,true,params);                          
104
                          migdal.close();
105
                  
106
                  }catch(Exception e){
107
                          e.printStackTrace( );
108
                          //...
109
                  }
110
                  
111
          
112
        }  
113
}