[gdal-dev] Reading NetCDF using VB.NET

Etienne Tourigny etourigny.dev at gmail.com
Thu Jun 14 11:51:11 PDT 2012


If you read the GDAL download page [1] you will find this:

"The latest FWtools version for Windows, 2.4.7, dates back to a
pre-1.6 GDAL version. In order to benefit from the latest and
greatest, you can refer to the other binary builds mentionned above."

If you want to support netcdf files, you should probably be using a
more recent gdal, at least 1.9

That means you should probably not use FWTools, and use the SDK from
Tamas Szekeres [3] - which according to [2] supports vb.net (C#)

[1] http://trac.osgeo.org/gdal/wiki/DownloadingGdalBinaries
[2] http://trac.osgeo.org/gdal/wiki/GdalOgrInCsharp
[3] http://vbkto.dyndns.org/sdk/

cheers
Etienne

On Thu, Jun 14, 2012 at 2:08 PM, Siebe Bosch <siebe at hydroconsult.nl> wrote:
> Hello all,
>
> I'm trying to build a command line application in VB.NET that extracts parts
> from a NetCDF file.
> For this I'm using the C# API as supplied with FWTools version 2.4.7. It's
> supposed to support VB.NET as well; am I right?
>
> However, the application already crashes at the line Call GDAL.Registerall()
> Here's the code:
>
> Imports System
> Imports OSGeo.GDAL
> Imports OSGeo.OGR
>
> Module MeteoBase
>
>  'Copyright Siebe Bosch Hydroconsult, 2012
>  'Lulofsstraat 55, unit 47 Den Haag, The Netherlands
>  'this program creates subsets from precipitation data in NetCDF-files
>  'as requested by the user. The program is designed to be called from
>  'a PHP-script.
>
>  Dim FileName As String
>  Dim ds As Dataset
>
>  Sub Main()
>    Dim DebugMode As Boolean
>
>    Console.WriteLine("This program extracts data from a NetCDF file")
>    Console.WriteLine("Path to the NetCDF file (*.cn)")
>    DebugMode = True
>
>    'start reading the command line arguments
>    If DebugMode Then
>      FileName = "c:\GDAL\PM\1990\EVAP_PM_19901231.nc"
>    Else
>      If My.Application.CommandLineArgs.Count = 0 Then
>        Console.WriteLine("Enter the path to the NetCDF-file:")
>        FileName = Console.ReadLine()
>      ElseIf My.Application.CommandLineArgs.Count <> 1 Then
>        Console.WriteLine("Error: incorrect number of arguments presented")
>      Else
>        FileName = My.Application.CommandLineArgs(0)
>      End If
>    End If
>
>    Try
>      'start reading the NetCDF File
>      Call Gdal.AllRegister()
>      ds = Gdal.Open(FileName, Access.GA_ReadOnly)
>      If ds Is Nothing Then
>        Console.WriteLine("Cannot open NetCDF file: " & FileName)
>        Throw New Exception
>      Else
>        Console.WriteLine("Raster dataset parameters:")
>        Console.WriteLine("  Projection: " + ds.GetProjectionRef())
>        Console.WriteLine("  RasterCount: " + ds.RasterCount)
>        Console.WriteLine("  RasterSize (" + ds.RasterXSize + "," +
> ds.RasterYSize + ")")
>      End If
>    Catch ex As Exception
>      Console.WriteLine("Error in sub Main of Meteobase")
>    End Try
>
>  End Sub
>
> End Module
>
> _______________________________________________
> gdal-dev mailing list
> gdal-dev at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/gdal-dev


More information about the gdal-dev mailing list