Current options for displaying Raster data

Topics: General Topics
Feb 7, 2007 at 12:44 AM
Hey everyone,

I'm guessing that there are lots of people out there who are making use of SharpMap for displaying vector and raster data. Can this be done without using the new GDALRasterLayer? I get errors when I try to display my imagery (GeoTIFF with projected coordinate system) using this layer and have already logged an issue regarding this.

Is there an alternate way of doing this? If so, please give me some tips on how to achieve it. SharpMap is perfect for all of my vector needs, but at the moment it is just missing on the raster display stuff.

Steve
Feb 7, 2007 at 6:17 AM
Okay, so soon after posting this I saw that Christian had gone back to using FWTools for doing all the raster stuff. I'd hoped this would solve my problems with projected imagery not working. After loading it all up, things were not working any differently. I still couldn't add in projected imagery without getting strange errors. Aargh!

So I've spent a couple of hours stuffing around and trying to figure out how a projected image could be any different to a lat/long image (in the eyes of GDAL). The only difference I could find is in the pixel size. Projected images usually have pixels with sizes > 1, while lat/long images usually have pixels with size < 1.

In the call to GDAL.Band.ReadRaster, the arguments should be:

ReadRaster(int xOff, int yOff, int xSize, int ySize, byte buffer, int bufxSize, int bufySize, int pixelSpace, int lineSpace)

The last two arguments, pixelSpace and lineSpace, must be integers and in the GDALRasterLayer they are defined using (int)GT.HorizontalPixelResolution, (int)GT.VerticalPixelResolution respectively. For lat/long images (which work fine), these come out as 0. For anything else, they are > 0 and cause an error.

I've simply edited the call to ReadRaster so that the last two arguments are both 0 and my problem with projected data has been solved. However, does anyone know the importance of these pixelSpace and lineSpace arguments. Will setting them both to 0 cause any other problems?

Steve
Coordinator
Feb 7, 2007 at 9:57 AM
Hi Steve,

This issue is already known and I'm working on.
BTW. Is the latest GdalRasterLayer with FwTools bindings working for you?

regards
Christian
Feb 7, 2007 at 9:48 PM
Christian,

You might have missed my second post on this discussion topic, talking about how I've overcome this problem. Please have a look at it and tell me whether you see this causing any other problems. If not, then I'd suggest implementing it into the soruce so that others don't have the same problem.

Steve
Feb 8, 2007 at 2:54 PM
Hey everyone,

Has anybody got it work with ecw files (size 30Mb)?
It's just saying loading in the ajax web sample.

In a previous version it works with NCSEcw.dll.

Regards
Michael
Coordinator
Feb 8, 2007 at 8:17 PM
Hi Michael,

What data layer do you use?
Appear this problem in a window forms app?

I use huge ( 1,7 GB ecw's ).

regards
Christian
Feb 8, 2007 at 10:29 PM
This works fine for me now, since changing the source code slightly. I'm using an 8gb ECW file, with 1m pixels in projected coordinates. SharpMap displays this very quickly and with all my vector data correctly placed on top.

Seems that putting in 0, 0 at the end of the ReadRaster line just forces GDAL to use the default values anyway.

Steve
Feb 9, 2007 at 8:36 AM
Hi Christian

I'm using the SharpMap.Layers.GdalRasterLayer and the build is 17835

I tried the demo website by changing the data layer.
Do you have a sample of the demo website with a ecw file?

Regards
Michael



molsen6 wrote:
Hi Michael,

What data layer do you use?
Appear this problem in a window forms app?

I use huge ( 1,7 GB ecw's ).

regards
Christian

Feb 9, 2007 at 11:45 AM
When using ecw file and the demo website(Simple.aspx) i get an error saying;

Exception Details: System.ApplicationException: Access window out of range in RasterIO(). Requested
(0,61955797) of size 7230805x61945787 on raster of 10030x10010.


Source Error:


Line 232: GDAL.Band band = dataset.GetRasterBand(i);
Line 233:
Line 234: band.ReadRaster(x1, y1, x1width, y1height, buffer, size.Width, size.Height, (int)GT.HorizontalPixelResolution, (int)GT.VerticalPixelResolution);
Line 235:
Line 236: //band.RasterIO(RWFlag.Read, x1, y1, x1width, y1height, buffer, size.Width, size.Height);

I have tried changing the ReadRaster to 0,0 in the end. No luck

regards
Michael