1

I have downloaded DEM data from this page: http://www.viewfinderpanoramas.org/dem3.html. I have written simple program in C++ that takes "bricks" and build resulting height map. Hovewer, I have problem with result. I am using Mercator projection and take every "gps pixel" from DEM data and recalculate its position to real pixels (same for border). It works fine (or at least it seams to).

As you can see on image, there is something weird. That "mess" in lower part is incorrect and I dont know, if data are incorrect, if I am using them incorrect (wrong bricks ?) or something in my program is wrong.

Height map of Czech Republic

EDIT:

Here is algorithm for reading "bricks" heights:

//iterate all bricks and set its starting coordinates
double startLon = 19;
double startLat = 48;

///-------------------------
int tileSize = 1201;
double step = 1.0 / tileSize;

for (int y = 0; y < tileSize; y++)
{       
   for (int x = 0; x < tileSize; x++)
   {

    short height = brick[x + (tileSize - 1 - y) * tileSize];
        //tileSize - 1 - y -> reverse brick coordinates

    height = swap_endian<short>(height);

    if (height == -32768)
    {               
        height = 0;
    }

    lon = (startLon) + x * step;
    lat = (startLat - 1) + y * step;

    int pixelX = 0;
    int pixelY = 0;
    this->helper->ConvertCoordinates(lon, lat, &pixelX, &pixelY);

    if (pixelX < 0) {  continue;}
    if (pixelY < 0) {  continue;}
    if (pixelX >= this->width) {  continue;}
    if (pixelY >= this->height) {  continue;}

        //write it to map
        //if multiple height in same pixel, take only last one
    this->heightMap[pixelX + pixelY * this->width] = height;            
    }
}
Martin Perry
  • 491
  • 2
  • 14
  • 1
    You need to share the details of your algorithm with us. From the image alone it is difficult (or impossible) to tell what is correct and what is incorrect about it. Showing a small, simple example of what is going wrong would serve you much better. For more guidance in asking questions here, please consider reading our [faq]. – whuber Jun 03 '13 at 17:38
  • Edit > Added algorithm – Martin Perry Jun 03 '13 at 18:15
  • Just a guess but looks like maybe an overflow problem? The change occurs at what looks like a break point or elevation. Have your tried changing short to long for height's type? – RomaH Jun 03 '13 at 18:41
  • It cant be overflow.. data are short (2 bytes / height) – Martin Perry Jun 03 '13 at 18:53
  • "I have written simple program in C++ that takes "bricks" and build resulting height map. Hovewer, I have problem with result. I am using Mercator projection and take every "gps pixel" from DEM data and recalculate its position to real pixels (same for border)." Can you explain in more details? What is a 'brick'? What is a 'gps pixel' and why do you want to recalculate its position? What are you trying to do with the DEM data (how is height being calculated?)? – Andre Silva Mar 29 '18 at 22:21

0 Answers0