Quantcast
Channel: DotSpatial
Viewing all articles
Browse latest Browse all 3973

Commented Unassigned: raster extent shifts from correct extent [26002]

$
0
0
Dear all,

as already seen in previous discussions (see [here](https://dotspatial.codeplex.com/discussions/294853))
there is a shift between the real raster extent and the one recovered with the library.
I noticed this problem when using the identify tool to recover raster cell values.
Visualization is shifted half cell to the left and half upward.

Couldn't find in dotspatial sources the origin of the problem

Can anyone help on that?
Thank you
Oscar
Comments: ** Comment from web user: Oscarafone77 **

I found what might cause the visualization shift.

In MapRasterLayer.cs to create the visualized Bitmap, the extent is given through the following instruction (somewhere around line 125):

```
var id = new InRamImage(bmp) { Bounds = { AffineCoefficients = raster.Bounds.AffineCoefficients } };
```
this assigns the same affine coefficients to the Bitmap.

If I substitute this assignment with this

```
double[] affine = new double[6];
affine[0] = raster.Bounds.AffineCoefficients[0] + raster.Bounds.AffineCoefficients[1] / 2.0;
affine[1] = raster.Bounds.AffineCoefficients[1];
affine[2] = raster.Bounds.AffineCoefficients[2];
affine[3] = raster.Bounds.AffineCoefficients[3] + raster.Bounds.AffineCoefficients[5]/2.0 ;
affine[4] = raster.Bounds.AffineCoefficients[4];
affine[5] = raster.Bounds.AffineCoefficients[5];

var id = new InRamImage(bmp) { Bounds = { AffineCoefficients = affine } };

```

I get the correct visualization.
I know this sounds more like a trick rather than a correct solution to the problem, but wrong raster visualization is very annoing

However this just to highlight that there is something to fix around affine coefficients definition

Oscar


Viewing all articles
Browse latest Browse all 3973

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>