[gdal-dev] Reading NetCDF using VB.NET
Etienne Tourigny
etourigny.dev at gmail.com
Sat Jun 16 13:08:28 PDT 2012
Sorry I thought that included pre-built libraries - perhaps someone
else can help here? I don't know much about building in windows, sorry
Etienne
On Sat, Jun 16, 2012 at 4:33 PM, Siebe Bosch <siebe at hydroconsult.nl> wrote:
> Following your third link, I had already found the section that reads:
>
> GDAL and MapServer build SDK packages (provides to compile MapServer and
> GDAL by yourself):
>
> I assumed that this meant that I had to compile the DLL myself. Hence my
> previous mail.
>
> Considering your last mail however I tried to look up a pre-built DLL inside
> the SDK, and I found this one:
> c:\GDALVS\release-1600\bin\gdal\csharp\gdal_csharp.dll
>
> Is this the correct one?
>
> I can add it to VS2008, however VS warns me that "the system cannot find the
> reference specified".
>
>
>
>
>
>
> On 14-06-12 20:51, Etienne Tourigny wrote:
>
> 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
>
>
>
> --
> ------------------------------------------
> Hydroconsult
> Lulofsstraat 55, unit 47
> 2521 AL Den Haag
> The Netherlands
>
> web: http://www.hydroconsult.nl
> e-mail: siebe at hydroconsult.nl
> phone: +31(0)70 250 0580
> mobile: +31(0)6 17 682 689
>
> actief lid van WaterForce.nu, het netwerk van
> zelfstandige professionals in het waterbeheer
> ------------------------------------------
More information about the gdal-dev
mailing list