Re: [gdal-dev] gdal ogr with java

Ivan Lucena ivan.lucena at pmldnet.com
Mon Mar 29 23:02:14 EDT 2010


Hi Zeng,

You are trying to load a Shapefile. Right?

That is supported by OGR, so you should call:

ogr.RegisterAll();

Before trying to open the file.

If you are going to open Raster with that same code you should keep your call to:

gdal.RegisterAll();

Regards,

Ivan

>  -------Original Message-------
>  From: zeng <xiaoxxcool at 163.com>
>  To: gdal-dev at lists.osgeo.org
>  Subject: [gdal-dev] gdal ogr with java
>  Sent: Mar 29 '10 21:21
>  
>  Hi, buddies
>  I am using gdal 1.7.1 with java banding, I got a problem when I run
>  the follow code, there is no out put message. And I am sure the file
>  exists, I have tried the relative code in c++, it works well. Any one knows
>  why?
>  //ShpTest.java
>  import java.io.IOException;
>  import org.gdal.gdal.gdal;
>  import org.gdal.ogr.DataSource;
>  import org.gdal.ogr.ogr;
>  public class ShpTest {
>  public static void main(String args[]) throws IOException {
>  String filename="f:/test/shp/states.shp";
>  gdal.AllRegister();
>  DataSource poDS = ogr.Open(filename);
>  if(poDS == null)
>  {
>  System.out.println(gdal.GetLastErrorMsg());
>  &n  bsp;           System.exit( 1 );
>  }
>  System.out.println("test ok");
>  poDS.delete();
>  }
>  }
>  
>  
>  --------------------
>  _______________________________________________
>  gdal-dev mailing list
>  [LINK: compose.php?to=gdal-dev at lists.osgeo.org] gdal-dev at lists.osgeo.org
>  [LINK: http://lists.osgeo.org/mailman/listinfo/gdal-dev]
>  http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list