Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geocoded(Georerenced) tif image load issue using GDAL Extension #1336

Open
rupakraj opened this issue Apr 28, 2020 · 3 comments
Open

Geocoded(Georerenced) tif image load issue using GDAL Extension #1336

rupakraj opened this issue Apr 28, 2020 · 3 comments

Comments

@rupakraj
Copy link

Hi,
I have a TIF image which is geocoded (georefenced) using gdal_translate. In DotSpatial demo application while trying to load the image it is not showing.

gdalinfo output showing the image is georeference with GCPs

Size is 673, 498
GCP[  0]: Id=1, Info=
          (74.1677165354332,263.116535433071) -> (622091.704797366,3065790.52791477,0)
GCP[  1]: Id=2, Info=
          (396.495275590551,467.806299212598) -> (622164.959733748,3065837.37023984,0)
GCP[  2]: Id=3, Info=
          (591.774015748032,392.51811023622) -> (622167.322796212,3065762.13862685,0)
GCP[  3]: Id=4, Info=
          (617.654330708662,67.8377952755906) -> (622140.383884123,3065751.25606648,0)
GCP[  4]: Id=5, Info=
          (311.796062992126,53.7212598425197) -> (622096.903534787,3065744.63189929,0)
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0,  498.0)
Upper Right (  673.0,    0.0)
Lower Right (  673.0,  498.0)
Center      (  336.5,  249.0)
Band 1 Block=673x3 Type=Byte, ColorInterp=Red
  Min=0.000 Max=255.000
  Minimum=0.000, Maximum=255.000, Mean=247.282, StdDev=34.553
  Mask Flags: PER_DATASET ALPHA
  Metadata:
    STATISTICS_MAXIMUM=255
    STATISTICS_MEAN=247.28208226666
    STATISTICS_MINIMUM=0
    STATISTICS_STDDEV=34.5533790588379
Band 2 Block=673x3 Type=Byte, ColorInterp=Green
  Mask Flags: PER_DATASET ALPHA
Band 3 Block=673x3 Type=Byte, ColorInterp=Blue
  Mask Flags: PER_DATASET ALPHA
Band 4 Block=673x3 Type=Byte, ColorInterp=Alpha

DotSpatial version: build of master

Expected behaviour

It was supposed to be loaded in the position where coding were applied as it does on the QGIS as below, the original image is shifted as it should be.

image
Fig: QGIS

Actual behaviour

Orginal image is as below:
image

On demo application the image is not shown as it was in QGIS, and also the image was actually flipped as below.
image
Fig:Translated Image

I tried to load the image manually using gdal extension as well on separate project

var imageData = DotSpatial.Data.Rasters.GdalExtension.GdalImage.Open(file); 
map.Layers.Add(imageData);

I tried map.AddLayer(); as well and still no luck. In custom application it is not even loaded.

Files

balambu_1KA.zip
balambu_1KA_georef.zip

How can we I fix this issue?

@VectorZita
Copy link
Contributor

I have reproduced the actual behavior. I suspect the problem is that DotSpatial is not currently handling this type of georeference information. Based on GDAL documentation regarding the Raster Data Model, there are two options to describe the raster space (the transformation), either an Affine Transformation, or GCPs. It is specifically stated that:

Normally a dataset will contain either an affine geotransform, GCPs or neither. It is uncommon to have both, and it is undefined which is authoritative.

In the posted file, the raster space transformation is described through GCPs. According to a statement from the same link:

The GDAL data model does not imply a transformation mechanism that must be generated from the GCPs … this is left to the application. However 1st to 5th order polynomials are common.

I have retrieved the GCPs in code from the posted balambu_1KA_georef.tif file, so I can confirm that this is actually stored within the file. Based on the DotSpatial source code, I can also confirm that GCPs are not treated anyhow as an alternative to undefined Affine Coefficients. Therefore, it is, indeed, a missing capability (unless I am missing something), which, I assume, would be similar to an on-the-fly transformation of the image using some transformation model.

@rupakraj Regarding your problem, the only way to get around it is to actually transform the image (i.e. use gdal_warp) properly (using the GCPs), in order to get the actual image you are seeing in QGIS as an output image and try to open this in a DotSpatial Map. I suspect QGIS is transforming the image on-the-fly using some transformation. Beyond that, setting GCPs through gdal_translate does not (again, unless I am missing something) transform the image, it only assigns GCP points as georeference data.

@rupakraj
Copy link
Author

rupakraj commented Apr 29, 2020

Thanks @VectorZita I used gdalwrap to fix this issue.
After enabling GDAL the color bands (symbology) is automatically assigned. Do you have any idea how can we disable this and load the image with the color as it has.

image

While going through details the image is mirrored OR flipped as well. How can we fix this?

Thanks a lot.

@sindizzy
Copy link
Contributor

sindizzy commented May 7, 2020

I had posted about such an issue a couple of years ago #1060

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants