help with m.nviz.image - no output

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

help with m.nviz.image - no output

Carlos Henrique Grohmann de Carvalho-2
Hello all

I'm trying to create some images with m.nviz.image, but all I get as output is a 11 byte ppm...

Some of the options are quite puzzling in terms of mixing units:

position=x,y
Viewpoint position (x,y model coordinates)

height=value
Viewpoint height (in map units)

focus=x,y,z
Focus to point on surface (from SW corner in map units)

So I have to convert my position coordinates from map units (say meters in UTM) to 0-1, I can use height in meters, and also need to do some math to get the position of the focus point in meters from the SW corner... 

Also, regardless of the output size, all I get is an unreadable ppm with 11 bytes. With format=tif, I get an error creating the file (TIFFScanlineSize64: Computed scanline size is zero.).

Opening the ppm file into a text editor, I see that all that was written was the header, and that the image size was 0,0:

P6
0 0
255

navigating trough the code, I see that m.nviz.image calls GS_write_ppm to write the file, which is in lib/ogsf/gsd_img_ppm.c:


int GS_write_ppm(const char *name)
{
    unsigned int x;
    int y;
    unsigned int xsize, ysize;
    FILE *fp;
    unsigned char *pixbuf;

    gsd_getimage(&pixbuf, &xsize, &ysize);

    if (NULL == (fp = fopen(name, "w"))) {
G_warning(_("Unable to open file <%s> for writing"), name);
return (1);
    }

    fprintf(fp, "P6\n%d %d\n255\n", xsize, ysize);

    for (y = ysize - 1; y >= 0; y--) {
for (x = 0; x < xsize; x++) {
   unsigned char r = pixbuf[(y * xsize + x) * 4 + 0];
   unsigned char g = pixbuf[(y * xsize + x) * 4 + 1];
   unsigned char b = pixbuf[(y * xsize + x) * 4 + 2];

   fputc((int)r, fp);
   fputc((int)g, fp);
   fputc((int)b, fp);
}

    }
    G_free(pixbuf);
    fclose(fp);

    return (0);
}


GS_write_ppm calls gsd_getimage to get the actual image data and size.

So it seems to me that gsd_getimage is not getting the image?




The goal is to reproduce a nadir-looking aerial view (airplane, UAV).

Is this even possible?

thanks





--
Prof. Carlos Henrique Grohmann
Institute of Energy and Environment - Univ. of São Paulo, Brazil
- Digital Terrain Analysis | GIS | Remote Sensing - 

http://orcid.org/0000-0001-5073-5572
________________
Can’t stop the signal.

_______________________________________________
grass-user mailing list
[hidden email]
https://lists.osgeo.org/mailman/listinfo/grass-user