svn-gvsig-desktop / trunk / libraries / libjni-gdal / src-test / CreateCopy.java @ 716
History | View | Annotate | Download (1.68 KB)
1 |
/**********************************************************************
|
---|---|
2 |
* $Id: CreateCopy.java 716 2004-12-28 14:07:11Z igbrotru $
|
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 |
|
12 |
import es.gva.cit.wrappergdal.*; |
13 |
import java.io.*; |
14 |
import java.util.Date; |
15 |
import java.util.StringTokenizer; |
16 |
|
17 |
public class CreateCopy{ |
18 |
public static void main(String[] args){ |
19 |
|
20 |
|
21 |
Gdal migdal=new Gdal();
|
22 |
Gdal dset_dstno=null;
|
23 |
|
24 |
GdalRasterBand mirasterband=null;
|
25 |
GdalRasterBand rband=null;
|
26 |
int nxsize=0; |
27 |
int nysize=0; |
28 |
int rastercount=0; |
29 |
float total=0; |
30 |
|
31 |
|
32 |
try{
|
33 |
if(args.length==1){ |
34 |
migdal.open(args[0],Gdal.GA_ReadOnly);
|
35 |
|
36 |
}else {
|
37 |
System.out.println("Params: filename"); |
38 |
System.exit(1); |
39 |
} |
40 |
}catch(Exception ge){ |
41 |
ge.printStackTrace(); |
42 |
//...
|
43 |
} |
44 |
|
45 |
|
46 |
try{
|
47 |
rastercount=migdal.getRasterCount(); |
48 |
nxsize = migdal.getRasterXSize(); |
49 |
nysize = migdal.getRasterYSize(); |
50 |
System.out.println("N BANDAS="+rastercount+" SIZEX="+nxsize+" SIZEY="+nysize); |
51 |
System.out.println(migdal.getProjectionRef());
|
52 |
}catch(GdalException ge){
|
53 |
ge.printStackTrace(); |
54 |
//...
|
55 |
} |
56 |
|
57 |
|
58 |
|
59 |
try{
|
60 |
//Obtenemos el driver y creamos el dataset del destino
|
61 |
|
62 |
GdalDriver drv=Gdal.getDriverByName("GTiff");
|
63 |
String[] params={"TILED=YES","PHOTOMETRIC=RGB","TFW=WORLDFILE"}; |
64 |
drv.createCopy("copia.gif",migdal,1,params); |
65 |
migdal.close(); |
66 |
|
67 |
}catch(Exception e){ |
68 |
e.printStackTrace( ); |
69 |
//...
|
70 |
} |
71 |
|
72 |
|
73 |
} |
74 |
} |