Global Mapper Pro

Not able to convert input in FEET to output files in FEET (always outputs in METERS)

codemouse Global Mapper UserTrusted User
edited November 2010 in SDK

I'm still having trouble getting my output rasters or vectors to show up in FEET, when the source is in FEET (they always convert to the default elevation of METERS). Let me explain what I'm doing EXACTLY via the GUI (which works), then explain what I'm doing programatically via the SDK (which does NOT WORK). Maybe you can point out what I am missing that needs to be done:

GUI - Global Mapper 11.02 32-bit (works):
1. Open Generic ASCII text file (YXZ formatted file in FEET)
2. Generic ASCII text file Import Options Screen (the rest are defaults)
- A. Import Type - Elevation Grid
- B. Y-first
- C. Coordinate Scale Z -1 (depth, not elevation)
3. Elevation Grid Creation Options (the rest are defaults)
- A. Vertical Units - FEET
- B. Ignore Zero Elevations
4. Set a Projection (I use WGS-1984)
6. Export - Arc ASCII Grid or GeoTIFF Raster or Shapefile Contours (if I generate).

Values come out correct.

Programatically (SDK 1.34 beta) (always outputs in Meters regardless of input):
1. call GM_SetProjection - to DATUM.GM_DATUM_WGS_84
2. call GM_SetVerticalDisplayOptions (for shader)
3. call GM_LoadGenericAsciiTextLayer and load file
4. call GM_GenerateContours (for shapefile export)
5. call GM_SetMiscOption (GM_MiscOpt_t32.GM_MiscOpt_SetVectorExportElevUnits and set to FEET specifically if import file is in FEET)
6. call GM_ExportVector Shapefile (shapefile) - ALWAYS in meters
7. call GM_ExportRaster (geotiff) - ALWAYS in meters
8. call GM_ExportElevation (arc ascii grid) - ALWAYS in meters

Now, programatically i have purposely NOT called GM_GenerateElevationGrid, and when exporting in METERS (if the source is in meters) this is, obviously, not seeming to be necessary. Do I need to call this in order to get FEET output OR is there some Elevation Grid flag (assuming there is a default that is always created when you import?) that I need to set in order to get Elevation information in FEET instead of METERS on all output files?



  • codemouse
    codemouse Global Mapper User Trusted User
    edited November 2010
    Something keeps telling me I need to utilize GM_ElevationOverrides_t* in conjunction with the raster layer outputs (arc ascii grid? and geotif)
  • global_mapper
    global_mapper Administrator
    edited November 2010

    For the GM_ExportElevation function there is a parameter to that function controlling the units the grid value are in. The GM_ExportRaster function is just going to generate a picture of whatever your contours look like, there won't be an elevation unit inherent to the GeoTIFF created by that function.

    What does your GM_LoadGenericAsciiTextLayer call look like? You might need to call GM_SetElevationOverrides on the layer generated by that function to set the elevation units (mElevUnits) to GM_PRJ_UNITS_FEET so that your elevation values are interpreted properly.

    Let me know if I can be of further assistance.


    Global Mapper Support
  • codemouse
    codemouse Global Mapper User Trusted User
    edited November 2010
    I keep getting GM_Error_InvalidParam. The notes say it wants a RASTER layer in. Here is my setup for this right after I import the ASCII layer:

    var options = new GM_ElevationOverrides_t
    mClampVals = 0,
    mElevUnits = GM_ElevUnits_t8.GM_ElevUnit_Feet,
    mLayerShader = null,
    mMaxElev = 0,
    mMaxValid = 0,
    mMinElev = 0,
    mMinValid = 0,
    mOffset = 0,
    mScale = 0,
    mVoidElev = 0,
    mVoidValid = 0

    Then I pass in the ascii layer handle I just imported, plus that object.

    The dllimport code looks like this:
    public delegate GM_Error_t32 GM_SetElevationOverrides(IntPtr aLayer, GM_ElevationOverrides_t aOptions);
  • codemouse
    codemouse Global Mapper User Trusted User
    edited November 2010
    also, the ascii layer load:

    var path = "path... etc";

    IntPtr layer;

    const GM_LoadFlags_t32 flags = GM_LoadFlags_t32.GM_LoadFlags_HideAllPrompts | GM_LoadFlags_t32.GM_LoadFlags_HideProgress;

    var mImportType = GM_AsciiImportType_t8.GM_AsciiImport_Elevation;
    var mCoordDelim = GM_AsciiCoordDelim_t8.GM_AsciiDelim_AutoDetect;
    byte mYCoordFirst = 1;
    byte mIncludeCoordAttrs = 0;
    byte mColumnHeadersInFirstRow = 0;
    byte mIncludeElevCoords = 1;
    byte mColumnsToSkip = 0;
    var mCoordLinePrefix = string.Empty;
    var mAreaType = AreaFeatureClass_t16.AFC_UNKNOWN;
    var mLineType = LineFeatureClass_t16.LFC_UNKNOWN;
    var mPointType = PointFeatureClass_t16.PFC_UNKNOWN;
    byte mIgnoreZeroElevations = 1;
    byte mFillToBounds = 0;
    var mOffsetX = 0;
    var mOffsetY = 0;
    var mOffsetZ = 0;
    var mScaleX = 1;
    var mScaleY = 1;
    var mScaleZ = -1;
    var mNoDataDistanceFactor = 0.0;
    var mBreakOnColumnIdx = IntPtr.Zero;

    var genericAsciiTextFileImportOptions = new GM_AsciiFormatInfo_t
    mImportType = mImportType,
    mCoordDelim = mCoordDelim,
    mYCoordFirst = mYCoordFirst,
    mIncludeCoordAttrs = mIncludeCoordAttrs,
    mColumnHeadersInFirstRow = mColumnHeadersInFirstRow,
    mIncludeElevCoords = mIncludeElevCoords,
    mColumnsToSkip = mColumnsToSkip,
    mCoordLinePrefix = mCoordLinePrefix,
    mAreaType = mAreaType,
    mLineType = mLineType,
    mPointType = mPointType,
    mIgnoreZeroElevations = mIgnoreZeroElevations,
    mFillToBounds = mFillToBounds,
    mOffsetX = mOffsetX,
    mOffsetY = mOffsetY,
    mOffsetZ = mOffsetZ,
    mScaleX = mScaleX,
    mScaleY = mScaleY,
    mScaleZ = mScaleZ,
    mNoDataDistanceFactor = mNoDataDistanceFactor,
    mBreakOnColumnIdx = mBreakOnColumnIdx

    var projection = _projection; // set earlier

    var globalMapperFunctionAddress = NativeMethods.GetProcAddress(_globalMapperInterfaceDllAddress, "GM_LoadGenericAsciiTextLayer");
    var globalMapperFunction = (GlobalMapper.GM_LoadGenericAsciiTextLayer)Marshal.GetDelegateForFunctionPointer(globalMapperFunctionAddress, typeof(GlobalMapper.GM_LoadGenericAsciiTextLayer));

    var lastGmError = globalMapperFunction(path, out layer, flags, ref genericAsciiTextFileImportOptions, ref projection);
  • codemouse
    codemouse Global Mapper User Trusted User
    edited November 2010
    I'm going to try this:

    // Sets the elevation units to use for 3D vector features without an elevation unit in the elevation attribute
    GM_DLL_EXPORTED GM_Error_t32 __stdcall GM_SetLayerElevationUnits
    GM_LayerHandle_t32 aLayer, // Layer to modify
    GM_ElevUnits_t8 aElevUnits // Elevation units to interpret values as
  • global_mapper
    global_mapper Administrator
    edited November 2010
    The result of the GM_LoadGenericAsciiTextLayer will be a raster layer since you are creating an elevation grid. Since it is a raster layer the GM_SetLayerElevationUnits won't do anything for you as it only affects 3D vector features, not elevation grids.

    Your declaration for GM_SetElevationOverrides is wrong. It should pass the GM_ElevationOverrides_t as a reference parameter so the pointer is passed. I would also suggest first calling GM_GetElevationOverrides, then changing the units, then calling GM_SetElevationOverrides rather than manually initializing the structure so you don't miss any future additions to the structure.

    Let me know if I can be of further assistance.


    Global Mapper Support
  • codemouse
    codemouse Global Mapper User Trusted User
    edited November 2010

    I'm sorry, it's definitely late and I was stating that incorrectly.

    Yes - tried exactly what you did. Better yet, GM_GetElevationOverrides proved to me the layer's metric was not originally set to FEET if it was imported as feet. So, I grabbed that options object and just set options.mElevUnits = GM_ElevUnits_t8.GM_ElevUnit_Feet. It seems like it MAY actually be working now. I will do some further testing...

    THANK you very much.

Sign In or Register to comment.