This project has moved and is read-only. For the latest updates, please go here.

Is there a GDALRasterLayer how to?

Topics: SharpMap v0.9 / v1.x
Jan 16, 2013 at 9:01 PM

I have been using SharpMap 0.90 with much success.  I downloaded and compiled the trunk 101083.  In the past, all I had to do was copy the dlls from FWTOOLS to the application to be able to view MrSid files.  I noted that this version is using a more recent GDAL 1.9.2 version which is why I would like to use it. After compiling my new application I copy the DLLS for the appropriate configuration to the output directory and have no joy.

To test if the GDAL binaries work I have installed the most current version (core and plugins (MrSid)) from here: on to my PC and I can work with MrSid files from the command line tools.  What am I missing. 

Any help would be appreciated.

Jan 16, 2013 at 9:52 PM
Edited Jan 16, 2013 at 9:53 PM

After compiling SharpMap.Extensions you should have a GDAL subdirectory in your output folder.

Either you copy all of that to the output folder of your application, or you add GDAL.Native and/or GDAL.Plugins nuget package to your application project. Btw, you can target for AnyCPU

Hth FObermaier

Jan 17, 2013 at 12:51 PM

Thanks for the quick reply.  I just tried the NuGet solution and the problem was resolved but I now get an error which I believe is related to another plugin.  The error is "The program can't start because OCI.dll is missing from your computer.  Try reinstalling the program to fix the problem."  I believe OCI.dl is related to the Oracle provider which I don't need or have.  I tried deleting the ogr_OCI.dll and Oracle.DataAccess.dll which did not solve the problem.  Any recommendations to eliminate this error.

Jan 17, 2013 at 1:05 PM
Edited Jan 17, 2013 at 1:12 PM

Quick and dirty: remove Oracle provider and its dependencies from the SharpMap.Extensions project.

Edit: OOPS it might be releated to GDAL package. Remove the ogr_oci dll's in the gdal\[x86|x64]\plugins folder as well

Hth FObermaier

Jan 17, 2013 at 1:07 PM

I will try that today.  Once again thanks for your quick response.

Jan 17, 2013 at 3:50 PM

Just an update.  I tried your suggestion and had some difficulty, so for testing purposes I downloaded the Oracle Instant Client and copied the OCI.dll to the bin and the app works as expected.  I will try and figure out what I am missing to remove the Oracle Provider.  Thanks for your help.




Jan 23, 2013 at 12:48 PM

In SharpMap.Layers.GdalRasterLayer containing a DEM how are accessible single cell data ?

Thanks in advance


Jan 23, 2013 at 12:57 PM

I've never used DEMs with GDAL but I found an article that uses the command line of GDAL. This might help.

Jan 23, 2013 at 1:25 PM

Interesting article but I need something much simpler. Assuming that in the layer is being uploaded a dem, is Z-values ​are in a two-dimensional matrix Z [i, j].

I have not found (surelly my fault) a method that I return the access to these data.

In this way I could for example apply a custom model or - as I'm trying - create contours from raster.

Jan 23, 2013 at 1:36 PM

I have been working on Polygonizing an image which is similar but not the same.  I use GDAL.Polygonize().  Still working out the method so I do not have fully functional working code.  But I looked at the GDAL docs and found the command line tool to create contour shapefiles.  and I also looked at intellisense and found the Gdal object has a CountourGenerate().

OSGeo.GDAL.Gdal.ContourGenerate(OSGeo.GDAL.Band, double, double, int, OSGeo.GDAL.SWIGTYPE_p_double, int, double, OSGeo.OGR.Layer, int, int, OSGeo.GDAL.Gdal.GDALProgressFuncDelegate, string)

I hope that helps.

Carlos Ortiz

Jan 23, 2013 at 1:50 PM

That surelly helps !

The problem is that I have to study something about GDal before try use them



Jan 23, 2013 at 1:51 PM

Good Luck

Jan 28, 2013 at 11:37 AM
Edited Jan 28, 2013 at 11:37 AM

I was reading something about GDal and (as usally) helps !  :-)  Now I can makes contours...

My proposal is set _gdalDataset member of GDalRasterLayer reflected as a public method (something like GDalDataset ? or simply Dataset) so functions like OSGeo.GDAL.Gdal.ContourGenerate or other operation on Raster can be done directely on the layer.




Apr 9, 2013 at 7:30 AM
I've also had an issue with the OCI.dll coming up as an error when I'm adding raster layer using GDAL..
I installed GDAL plugins using nuGet
SharpMap.Layers.GdalRasterLayer rasterLayer = new SharpMap.Layers.GdalRasterLayer("Aerial", @"E:\Data\Aerial.ecw");
after the errors everything still works fine... (just annoying errors popping up)
is there a fix for this other than installing Oracle Client.... I don't have the OCI.dll laying around and
I don't really want to have to install Oracle Client to get the OCI.dll when I'm not planning on using Oracle at all.....

any help would be appreciated


Apr 9, 2013 at 8:07 AM
If you do not want to install an Oracle client, just remove the ogr_oci dll's in the gdal[x86|x64]\plugins folder.

For the upcoming GDAL 1.10 package I will put the gdal oracle stuff in a separate package.

Hth FObermaier
Apr 10, 2013 at 12:58 AM
FObermaier wrote:
If you do not want to install an Oracle client, just remove the ogr_oci dll's in the gdal[x86|x64]\plugins folder.

For the upcoming GDAL 1.10 package I will put the gdal oracle stuff in a separate package.

Hth FObermaier
Hi Fobermaier, thanks for quick reply...
I've removed them from every gdal folder I have... still getting those errors... anything else I should be doing ?
Apr 10, 2013 at 8:52 AM
Do you use precompiled binaries?

If you do, you might need to recompile SharpMap.Extensions project without OracleProvider. Don't forget to remove the reference to the oracle client

Hth FObermaier
Oct 7, 2013 at 5:43 PM
Edited Oct 7, 2013 at 5:44 PM
I'm having the same problem about the OCI dll. The solution is not to delete the ogr_oci.dll file, I'm using the precompiled binary and I was expecting that it di not have external strong dependencies like the Oracle client. I'm going to try to recompile the extention source to remove that dependency, I think anyway that this clean separation should be made inside SM, or otherwise include all the necessary files inside the package. Also a release note is opportune.