mPixelSize in LayerInfo

QiaoQiao Global Mapper UserPosts: 74Trusted User
edited May 2012 in SDK
Hi Mike,

When we use Global Mapper to load a GeoTiff file with meter as projection planar unit, it shows correctly the spacing of the image in Pixel_Scale (Pixel_Width & Pixel_Height too except the fourth digit is truncated, right?) of the metadata window. However, when we use SDK's GM_GetLayerInfo(), the returned mPixelSizeX and mPixelSizeY are slightly different than the correct ones (e.g., 2.000000 becomes 2.0007579857619753).

Is that true that in SDK, even the input projection is in meters, it will re-calculate the mPixelSizeX/mPixelSizeY based on the goegraphical (degrees) extents? Do you have any comments on that?

Thanks,

Qiao

Comments

  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited July 2009
    Qiao,

    Yes, the mPixelSizeX and mPixelSizeY values are calculated based on the actual size of the image using the Vincenty distance calculation and not the less accurate projected distance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • Yann DUPUYYann DUPUY Global Mapper User Posts: 33Trusted User
    edited May 2012
    Hi Mike,

    sorry for digging up an old thread but I need some explanations.
    I'm trying to export LANDSAT rasters with the "best" pixel resolution. I was expecting to find such information within the GM_LayerInfo_t structure, in the mPixelSizeX and mPixelSizeY parameters. But I really don't understand the value I can find there!

    For instance, loading a [1; 1.5] [43.5; 44] rectangle with the SDK, I have
    mPixelSizeX 7.9482874971255688
    mPixelSizeY 7.9482874971255688

    I was expecting something like 30 meters which is Landsat common precision (without panchromatique data).

    If I load the same data with GlobalMapper application and display the metadata, the pixel width and height are
    PIXEL WIDTH=0.0004883 arc degrees
    PIXEL HEIGHT=0.0004883 arc degrees

    If I consider the minute of arc length being 1852 meters, it would give something like
    mPixelSizeX = 0.0004883 * 60 * 1852 * cos(latitude=44°) = 39 meters
    mPixelSizeY = 0.0004883 * 60 * 1852 = 54 meters

    And this the result I have if I measure the drawn pixels in GlobalMapper view.

    So where do these nearly 8 meters come from ?

    Thanks for your help,
    Yann
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited May 2012
    Yann,

    Which version of the SDK are you using? Are you loading the Landsat imagery from a local file or from an online source? The pixel size reported in mPixelSizeX and mPixelSizeY should basically just be the distance in meters along a line crossing through the center of the image in the horizontal or vertical direction divided by the pixel width or height as appropriate.

    Your other calculations do seem correct though.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • Yann DUPUYYann DUPUY Global Mapper User Posts: 33Trusted User
    edited May 2012
    Mike,

    I am using SDK 13.1 and loading Landsat Imagery from provided online source (I tried 13.2 and noticed the difference in Landsat resolution, as mentionned in the release notes).
    I am using Global Mapper 11.02 to check things.

    Pixel width and height are set to 0 after a call to

    status = GM_LoadOnlineLayer(server, &boundingRect, &layer, 0);
    const GM_LayerInfo_t *layerInfo = GM_GetLayerInfo(layer);

    and I want to do something like

    GM_ExportRaster(filename, GM_Export_GeoTIFF, layer, 0, sizeX, sizeY, GM_ExportFlags_HideProgress);

    to use my "filename" texture as intended. That's why I thought I could use the mPixelSize and mGlobalRectangle to deal with it.

    Thanks,
    Yann
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited May 2012
    Yann,

    The mPixelSizeX and mPixelSizeY will be the resolution of the most detailed layer in the online Landsat layer. Online layers don't have a native pixel width and height as the pixel dimensions depend on the zoom scale you are accessing the layer at.

    For the Landsat layer in Global Mapper v13.2 application I get the following metadata:

    FILENAME=
    DESCRIPTION=WMS Global Mosaic, pan sharpened
    UPPER LEFT X=-94.3460738171
    UPPER LEFT Y=39.0442623607
    LOWER RIGHT X=-94.3280226967
    LOWER RIGHT Y=39.0377210524
    WEST LONGITUDE=94° 20' 45.4937" W
    NORTH LATITUDE=39° 02' 40.0680" N
    EAST LONGITUDE=94° 19' 39.6239" W
    SOUTH LATITUDE=39° 02' 15.0291" N
    PROJ_DESC=Geographic (Latitude/Longitude) / WGS84 / arc degrees
    PROJ_DATUM=WGS84
    PROJ_UNITS=arc degrees
    EPSG_CODE=4326
    COVERED AREA=0.4381 sq mi
    PIXEL WIDTH=0.0001221 arc degrees
    PIXEL HEIGHT=0.0001221 arc degrees
    BIT_DEPTH=24

    As you can see the pixel width and height are 0.0001221 arc degrees, which is consistent with the 7.9 meters per pixel reading you are getting. This is what I would expect as the Landsat data is natively 15m resolution, so the highest zoom level on the server is the 7.9m zoom scale as the next one up (about 16 meters) can't quite capture the full resolution of the data.

    Thanks,

    Mike
    Global Mapper Guru
    gmsupport@bluemarblegeo.com
    http://www.globalmapper.com
  • sisocanosisocano Posts: 4
    Hi
    Global Mapper Guru

    I have a simple question about calculating width and lenght in km of DEM .*flt files using header data .*hdr
    so i have :

    ncols         1240
    nrows         760
    xllcorner     9,4371914430
    yllcorner     34,4300096770
    xdim          0,00032722957580642
    ydim          0,00026934061315784

    Area dimension calculated by globalMapper in Projection GeoGraphic (Lat/Lon) WGS84  is 37.29 x 22.07 km


    if i use this rule :

    Lenght/Width = PixelSize * ncols/nrows   that give me worng value.

    1240 * 0,00026934061315784 = 0,3339823603157216

    760  * 0,00032722957580642 = 0,2486944776128792

    i want to know if there is any way to calculate distances ?






  • MykleMykle Global Mapper User Posts: 443Trusted User
    edited July 2
    Length = ncols * xdim = 0,40576
    Are you calculating Length = ncols * Ydim ??
    If your units are angular (degrees), it's more complicated than that. 
Sign In or Register to comment.