Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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;            
    }
}
share|improve this question
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 3 '13 at 17:38
    
Edit > Added algorithm –  Martin Perry Jun 3 '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 3 '13 at 18:41
    
It cant be overflow.. data are short (2 bytes / height) –  Martin Perry Jun 3 '13 at 18:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.