Arc ASCII Grid Export header

2»

Comments

  • codemousecodemouse Global Mapper User Posts: 186Trusted User
    edited September 2010
    This makes sense.

    So my global rectangle is:

    mMaxX = -30.000131102362204
    mMaxY = 59.999868897637796
    mMinX = -29.966568897637796
    mMinY = 60.0334311023622

    The original ascii file layer sample spacing was 2 minutes (let's just say). So I'm lost - shrink it by 1 minute on each coord? That won't work, I'll be down to a single point in THIS instance. :)

    Brian
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited September 2010
    You just need to take the global rectangle width divided by the global pixel width (and the same for the height) to get the sample spacing in the current projection system.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited September 2010
    If your original sample spacing was 2 minutes, then you would shrink the bounding box by 1 minute in each coordinate. Don't use mPixelSizeX and mPixelSizeY as that is an estimate of the pixel size in meters and you need the pixel size in the current projection units, which is arc degrees in this case.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • codemousecodemouse Global Mapper User Posts: 186Trusted User
    edited September 2010
    This, for width/height of ExportElevation is not working so nicely:

    var globalRectangleWidth = _asciiLayerInfo.mGlobalRect.mMaxX - _asciiLayerInfo.mGlobalRect.mMinX;
    var globalRectangleHeight = _asciiLayerInfo.mGlobalRect.mMaxY - _asciiLayerInfo.mGlobalRect.mMinY;

    var widthSampleSpacing = globalRectangleWidth / _asciiLayerInfo.mGlobalPixelWidth;
    var heightSampleSpacing = globalRectangleHeight / _asciiLayerInfo.mGlobalPixelHeight;

    var pixelWidth = (int)(_asciiLayerInfo.mGlobalPixelWidth - (widthSampleSpacing / 2));
    var pixelHeight = (int)(_asciiLayerInfo.mGlobalPixelHeight - (heightSampleSpacing / 2));
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited September 2010
    Your sample spacing calculations are correct, but you are adjusting the wrong thing at the end. You need to adjust your bounding rectangle that you pass in by one half the sample spacing, not the pixel dimensions. So your new mMinX would be ( _asciiLayerInfo.mGlobalRect.mMinX + widthSampleSpacing / 2.0 ). Do the same for the other rectangle values.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • codemousecodemouse Global Mapper User Posts: 186Trusted User
    edited September 2010
    pixelWidth/Height can stay as var pixelWidth = (int)_asciiLayerInfo.mGlobalPixelWidth ? etc... ?
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited September 2010
    Yes, don't change anything but the bounding rectangle that you are providing.
  • codemousecodemouse Global Mapper User Posts: 186Trusted User
    edited September 2010
    Bingo... this worked - except one thing NCOLS is still showing up as 129 instead of 128. Thoughts?

    globalRectangle.mMaxX -= widthSampleSpacing / 2;
    globalRectangle.mMinX += widthSampleSpacing / 2;
    globalRectangle.mMaxY -= heightSampleSpacing / 2;
    globalRectangle.mMinY += heightSampleSpacing / 2;
  • codemousecodemouse Global Mapper User Posts: 186Trusted User
    edited September 2010
    In the GUI version with 128 cols, the last column is (-9999)

    In the programmatic version with 129 cols, the last TWO columns are (-9999 -9999)
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited September 2010
    I took a look and found that in the GUI the pixel count was always rounded to the nearest whole number (as it should be), while in the SDK it was always rounded up. I have updated the SDK to round to the nearest number like the GUI and placed a new build at http://www.globalmapper.com/GlobalMapperSDK_v134_beta.zip for you to try.

    Let me know if I can be of further assistance.

    Thanks,

    Mike
    Global Mapper Support
    support@globalmapper.com
  • codemousecodemouse Global Mapper User Posts: 186Trusted User
    edited September 2010
    Magnifique!

    This works nicely. Thank you. I will be testing this out more tomorrow, but this is looking just about right at this point. I find it amusing in the programmatic version I gain an extra decimal place on cellsize, but it's pretty trivial:

    SDK
    cellsize 0.00026220472440943

    GUI
    cellsize 0.0002622047244094

    Just thought I'd mention.

    Thank you for your help on this. This was very beneficial for what we are doing!

    Brian
  • codemousecodemouse Global Mapper User Posts: 186Trusted User
    edited December 2013
    Mike,

    In newer versions of the SDK I am receiving inconsistent behavior with GM_ExportFlags_ForceSquareSamples - I'm going to try to dig up the older version of the SDK I have lying around (from 9/2010) to see if the issue goes away. Do you know if the force square option broke on later versions when utilizing via GM_ExportElevation?

    Brian
  • codemousecodemouse Global Mapper User Posts: 186Trusted User
    edited December 2013
    Mike,

    GM_ExportFlags_ForceSquareSamples works in a version of an SDK I have dated 10/9/2010 12:21pm - version 1.34.0.0 - but it doesn't seem like the logic for this ever integrated into future SDK builds and/or it seems to possibly have the issue where it will run sometimes but not others (look back in this thread). Can you confirm? I cannot seem to get it really work in newer SDK versions at all.

    If you cannot make a fix - can I ask if you have an older SDK version binary available? I have a copy of the 32-bit binaries but I'm lacking the 64-bit from this build I'm referencing.

    Brian
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited December 2013
    Brian,

    I took a look and indeed the force square pixels option wasn't being done properly for elevation exports. I've fixed this and placed a new build at http://www.globalmapper.com/GlobalMapperSDK_v15_latest_beta.zip so it should work properly for you now.

    Thanks,

    Mike
    Global Mapper Guru
    geohelp@bluemarblegeo.com
    Global Mapper
  • codemousecodemouse Global Mapper User Posts: 186Trusted User
    edited December 2013
    Mike - thanks!

    Brian
Sign In or Register to comment.