Jump to content

 
Photo

Compiling GDAL with HDF4-support

- - - - -

  • Please log in to reply
7 replies to this topic

#1
David_1980

David_1980

    Newbie

  • New Member
  • Pip
  • 3 posts
  • No Country Selected

I need GDAL with both Shapefile and HDF4-Support, if possible in 64 bit.
Since the normal GDAL-versions from http://www.gisinternals.com/sdk/ have Shapefile, but no HDF4 and the version from FWTools
has HDF4, but no Shapefiles, Im afraid I have to compile a GDAL-version by myself.
The problem is that Im 'just' a geographer with programming skills, but no real IT-expert, and Ive never compiled open source by myself,
so maybe my question is quite simple for you. :)

First Ive downloaded the source code from http://trac.osgeo.or.../DownloadSource.
The I opened makegdal90.vcproj with Visual Studio 2010. It needed to do some updates, then it opened.
If I compile it without changes, I get a GDAL-folder with a new GDAL19.dll.
If I try to use this whole folder in my C#-project that works with normal GDAL-versions, I get a error.
But if I only copy the new GDAL19.dll over the old one in the existing GDAL(32 bit)-folder it works.
Is this how it should be or is something going wrong here already ?

The second step is to switch to 64bit, in nmake.opt I changed the following entry:
# Uncomment the following if you are building for 64-bit windows
# (x64). You'll need to have PATH, INCLUDE and LIB set up for 64-bit
# compiles.
WIN64=YES
Then I changed the setting of the VS-project to X64 and compiled again.
It still works as before: I get a new GDAL19.dll that works fine in my old GDAL(64 bit)-folder.

But then I cant do the third step, including HDF4. I found and changed the following section in nmake.opt:
# Uncomment the following and update to enable NCSA HDF Release 4 support.
HDF4_PLUGIN = NO
HDF4_DIR = C:\HDF
HDF4_LIB = /LIBPATH:$(HDF4_DIR)\lib Ws2_32.lib
I tried it maybe 100 times, but it never worked. Sometimes I get a corrupt GDAL19.dll, sometimes I get >100 errors when compiling
and sometimes I get a working GDAL19.dll without HDF4-support. I've read almost every Google-hit in English and German I found,
but it never worked. One problem is that the files mentioned there do not exist in the HDF-versions Ive downloaded. I guess, this
tips were for much older versions of GDAL and HDF4.

So can anybody give a step by step tutorial "How to compile GDAL with HDF4 for dummies" ? ;)
I need to know which HDF4-files I need, where to get them, and what exactly I have to write in nmake.opt.
Or is there a ready to use GDAL-download with HDF4 and Shapefiles somewhere ?
(32 bit would be OK to, that isnt that important)

#2
frax

frax

    Hall of Fame

  • Associate Admin
  • PipPipPipPipPipPipPip
  • 2,299 posts
  • Gender:Male
  • Location:Stockholm, Sweden
  • Interests:music, hiking, friends, nature, photography, traveling. and maps!
  • Sweden

Isn't there an osgeo or gdal mailing list that could provide better response? I had some issue at one point, I remember, and I managed to find an IRC group, where I chatted with Frank Warmerdam and got it resolved (FW is mr GDAL)
Hugo Ahlenius
Nordpil - custom maps and GIS
http://nordpil.com/
Twitter

#3
chandlersterling

chandlersterling

    Newbie

  • Validated Member
  • Pip
  • 2 posts
  • United States

Isn't there an osgeo or gdal mailing list that could provide better response? I had some issue at one point, I remember, and I managed to find an IRC group, where I chatted with Frank Warmerdam and got it resolved (FW is mr GDAL)


Yes, find the GDAL IRC group on freenode. FrankW helped me through many issues I had with GDAL, and other developers are often in there to help as well.

#4
mdsumner

mdsumner

    Key Contributor

  • Validated Member
  • PipPipPip
  • 96 posts
  • Australia

Try installing GDAL/OGR with OSGeo4W, my installation has the HDF drivers (HDF4, HDFImage, HDF5, HDF5Image) with it on Windows 7. You can include (or add/remove later) optional features and drivers with the "Advanced Install" option.

http://trac.osgeo.org/osgeo4w/

I'm not sure about 64-bit versions, I have not built GDAL for a few years (a colleague did it including HDF4), but last time I looked you could not build for 64-bit using the free version of Visual Studio.

I need GDAL with both Shapefile and HDF4-Support, if possible in 64 bit.
Since the normal GDAL-versions from http://www.gisinternals.com/sdk/ have Shapefile, but no HDF4 and the version from FWTools
has HDF4, but no Shapefiles, Im afraid I have to compile a GDAL-version by myself.
The problem is that Im 'just' a geographer with programming skills, but no real IT-expert, and Ive never compiled open source by myself,
so maybe my question is quite simple for you. :)

First Ive downloaded the source code from http://trac.osgeo.or.../DownloadSource.
The I opened makegdal90.vcproj with Visual Studio 2010. It needed to do some updates, then it opened.
If I compile it without changes, I get a GDAL-folder with a new GDAL19.dll.
If I try to use this whole folder in my C#-project that works with normal GDAL-versions, I get a error.
But if I only copy the new GDAL19.dll over the old one in the existing GDAL(32 bit)-folder it works.
Is this how it should be or is something going wrong here already ?

The second step is to switch to 64bit, in nmake.opt I changed the following entry:
# Uncomment the following if you are building for 64-bit windows
# (x64). You'll need to have PATH, INCLUDE and LIB set up for 64-bit
# compiles.
WIN64=YES
Then I changed the setting of the VS-project to X64 and compiled again.
It still works as before: I get a new GDAL19.dll that works fine in my old GDAL(64 bit)-folder.

But then I cant do the third step, including HDF4. I found and changed the following section in nmake.opt:
# Uncomment the following and update to enable NCSA HDF Release 4 support.
HDF4_PLUGIN = NO
HDF4_DIR = C:\HDF
HDF4_LIB = /LIBPATH:$(HDF4_DIR)\lib Ws2_32.lib
I tried it maybe 100 times, but it never worked. Sometimes I get a corrupt GDAL19.dll, sometimes I get >100 errors when compiling
and sometimes I get a working GDAL19.dll without HDF4-support. I've read almost every Google-hit in English and German I found,
but it never worked. One problem is that the files mentioned there do not exist in the HDF-versions Ive downloaded. I guess, this
tips were for much older versions of GDAL and HDF4.

So can anybody give a step by step tutorial "How to compile GDAL with HDF4 for dummies" ? ;)
I need to know which HDF4-files I need, where to get them, and what exactly I have to write in nmake.opt.
Or is there a ready to use GDAL-download with HDF4 and Shapefiles somewhere ?
(32 bit would be OK to, that isnt that important)



#5
mdsumner

mdsumner

    Key Contributor

  • Validated Member
  • PipPipPip
  • 96 posts
  • Australia

BTW, what makes you think that FWTools does not have the ESRI Shapefile driver? It always did for the builds I used.

What makes you think it's not there? You should see it near the top of the list with ogrinfo --formats.

#6
David_1980

David_1980

    Newbie

  • New Member
  • Pip
  • 3 posts
  • No Country Selected

We've got the commercial version of VS 2010, it is able to compile GDAL (without HDF4) or other applications in 64 bit.

About FWTools:
I found out it should have Shapefiles from another tip yesterday, but for some reason, C# doesnt recognize any feature-type-drivers, trying to show the ogr-drivers throws an exception when using the FW-Tools-GDAL. With other GDAL-version the same code works fine, thats why I thought FWTools has only raster-drivers build in.

The error is:
The type-initialiser for "OSGeo.OGR.Ogs" has caused an exception.
System.EntryPointNotFoundException: The entry point "CSharp_OLCDeleteField_get" was not found in the DLL "ogr_wrap".
at OSGeo.OGR.OgrPINVOKE.OLCDeleteField_get()
at OSGeo.OGR.Ogr..cctor()
(translated from German by myself)

My code for that:
(..)
//Without Ogr.RegisterAll() it works fine:
Ogr.RegisterAll();
(..)
for (int i = 0; i < Ogr.GetDriverCount(); i++)
Console.WriteLine(Ogr.GetDriver(i).name);
(..)

As said, the same code works if Im using another version of GDAL, I already created a lot of shapefiles with it. (32 or 64 bit)

@frax:
To be honest, I asked in several forums, including the official mailing-list-web-interface. ;)
At least I have found out that there is a tool for converting HDF4 to HDF5 and that FWTools should work with Shapefiles, so there are 2 new options. But Ive got no new hints about compiling GDAL+HDF until now.

PS.:
I already tried OSGeo4W some time ago, but as far as I remember it didnt work at all, maybe its worth another try..

Edited by David_1980, 30 August 2012 - 02:16 AM.


#7
mdsumner

mdsumner

    Key Contributor

  • Validated Member
  • PipPipPip
  • 96 posts
  • Australia

FWTools is really out of date, so I doubt it's sensible to compare. I would check assumptions with the GDAL utilities first.

We've got the commercial version of VS 2010, it is able to compile GDAL (without HDF4) or other applications in 64 bit.

About FWTools:
I found out it should have Shapefiles from another tip yesterday, but for some reason, C# doesnt recognize any feature-type-drivers, trying to show the ogr-drivers throws an exception when using the FW-Tools-GDAL. With other GDAL-version the same code works fine, thats why I thought FWTools has only raster-drivers build in.

The error is:
The type-initialiser for "OSGeo.OGR.Ogs" has caused an exception.
System.EntryPointNotFoundException: The entry point "CSharp_OLCDeleteField_get" was not found in the DLL "ogr_wrap".
at OSGeo.OGR.OgrPINVOKE.OLCDeleteField_get()
at OSGeo.OGR.Ogr..cctor()
(translated from German by myself)

My code for that:
(..)
//Without Ogr.RegisterAll() it works fine:
Ogr.RegisterAll();
(..)
for (int i = 0; i < Ogr.GetDriverCount(); i++)
Console.WriteLine(Ogr.GetDriver(i).name);
(..)

As said, the same code works if Im using another version of GDAL, I already created a lot of shapefiles with it. (32 or 64 bit)

@frax:
To be honest, I asked in several forums, including the official mailing-list-web-interface. ;)
At least I have found out that there is a tool for converting HDF4 to HDF5 and that FWTools should work with Shapefiles, so there are 2 new options. But Ive got no new hints about compiling GDAL+HDF until now.

PS.:
I already tried OSGeo4W some time ago, but as far as I remember it didnt work at all, maybe its worth another try..



#8
David_1980

David_1980

    Newbie

  • New Member
  • Pip
  • 3 posts
  • No Country Selected

Maybe I need another(older) version of the GDAL-C#-bindings to use the Shapefile-support from the FW-Tools-GDAL ?
As said, the raster-formats are already working, if I could use Shapefiles at the same time, it would be enough for now.
(Maybe we would need a newer version of GDAL later, but one step after the other..)

Has anbody of you used the FW-Tools-GDAL in a C#-project ?




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

-->