/********************************************************************** * $Id$ * * Name: writetif.java * Project: gvSIG - Generalitat Valenciana SIG * Purpose: Ejemplo para la prueba del interfaz java de la libreria * gdal de Frank Warmerdam * Author: Nacho Brodin, brodin_ign@gva.es * **********************************************************************/ /* gvSIG. Sistema de Información Geográfica de la Generalitat Valenciana * * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. * * For more information, contact: * * Generalitat Valenciana * Conselleria d'Infraestructures i Transport * Av. Blasco Ibáñez, 50 * 46010 VALENCIA * SPAIN * * +34 963862235 * gvsig@gva.es * www.gvsig.gva.es * * or * * IVER T.I. S.A * Salamanca 50 * 46005 Valencia * Spain * * +34 963163400 * dac@iver.es */ import es.gva.cit.jgdal.*; import java.io.*; import java.util.Date; import java.util.StringTokenizer; public class CreateCopy{ public static void main(String[] args){ Gdal migdal=new Gdal(); Gdal dset_dstno=null; GdalRasterBand mirasterband=null; GdalRasterBand rband=null; int nxsize=0; int nysize=0; int rastercount=0; float total=0; try{ if(args.length==1){ migdal.open(args[0],Gdal.GA_ReadOnly); }else { System.out.println("Params: filename"); System.exit(1); } }catch(Exception ge){ ge.printStackTrace(); //... } try{ rastercount=migdal.getRasterCount(); nxsize = migdal.getRasterXSize(); nysize = migdal.getRasterYSize(); System.out.println("N BANDAS="+rastercount+" SIZEX="+nxsize+" SIZEY="+nysize); System.out.println(migdal.getProjectionRef()); }catch(GdalException ge){ ge.printStackTrace(); //... } try{ //Obtenemos el driver y creamos el dataset del destino GdalDriver drv=Gdal.getDriverByName("GTiff"); String[] params={"TILED=YES","PHOTOMETRIC=RGB","TFW=WORLDFILE"}; drv.createCopy("copia.gif",migdal,true,params); migdal.close(); }catch(Exception e){ e.printStackTrace( ); //... } } }