Loading ECW

Topics: Data Access
Jun 7, 2007 at 8:45 PM
I have read all of the posts concerning ECW and http://www.codeplex.com/SharpMap/Wiki/View.aspx?title=ECW
, but have still not found a solution for loading an ECW file.

I have the SharpMap source and have added the EcwRasterLayer class to the Layers directory as an existing item.
I downloaded the ECW SDK, which has the following dlls: NCScnet.dll, NCSEcw.dll, NCSEcsC.dll, and NCSUtil.dll.

The EcwRasterLayer class will not compile because it can't find the NCSECWLib namespace. I am guessing that I somehow need to reference the NCScnet.dll, but Visual Studio 2005 says that it is not a valid assembly. Also, the wiki, states that there needs to be an "interop reference to NCSECWLib.dll". Where does this go? Don't interop references necessarily precede extern methods with a DllImport annotation?

Thanks in advance for your help!
Perry
Jun 7, 2007 at 11:44 PM
Try register in COM (regsvr32) a NCSEcw.dll and add a COM reference in your project.
Regards from Argentina
Leandro
Jun 8, 2007 at 3:17 AM
yup. Register like this:

regsvr32 "C:\Program Files\Earth Resource Mapping\ECW SDK\redistributable\vc71\NCSUtil.dll"
for each file.

then... add this to the maphelper

SharpMap.Layers.EcwRasterLayer Marble = new SharpMap.Layers.EcwRasterLayer("The Good Earth", HttpContext.Current.Server.MapPath(@"~\App_data\world\world-topo-bathy-200407-3x86400x43200.ecw"));
Marble.SRID = 4326;

map.Layers.Add(Marble);

go to:

http://www.jodyford.com

fyi. I'm adding an ajax aoi (drag a box over the map) query function to my maps. I've also added a custom graphic layer you could use to add a logo (like me) or a center point indicator, or a rose compas to the maps.

good luck.

Jody


Jun 8, 2007 at 8:17 PM
Thanks Jody! I can now compile, but nothing is displayed when I add the EcwRasterLayer.

I tried it in both the DemoWinForm project and my own very simple project. My code looks like this:

public partial class Form1 : Form
{
public Form1( )
{
InitializeComponent( );
}

private void Form1_Load( object sender, EventArgs e )
{
EcwRasterLayer ecw = new EcwRasterLayer("Urban", @"path to my ecw file");
ecw.SRID = 4326;

_mapImage.Map.Layers.Add( ecw );
}
}

I can see in the debugger that the EcwRasterLayer was constructed properly and that it was successfully added as a Layer.

Just in case my ECW header is wrong, I tried multiple ECWs with no success.

Any pointers?

Perry
Jun 20, 2007 at 12:29 PM
Hi Jodyford,
Can I have your sourcecode, i like to try with ECW Raster Image.

Thanks