Calculating Viewshed with VB.NET

AzularAzular Global Mapper UserPosts: 3
edited March 2009 in SDK
I need to calculate viewshed programmaticaly using VB.NET. So I have some questions
1. How do I define the DEM file programmatically?Can I use an esri grid file as input and how to define it as parameter in viewshed function?
2. Does it generate a vector file or a raster as result and how do I save the result permanently as file in disk?
Thank you


  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2009
    You simply need to first load the DEM file(s) that you want to use in the view shed using the GM_LoadLayerList function. They will them be available to use during view shed calculation and will be used by default if you just pass in an empty input layer list to the GM_CalcViewShed function.

    The view shed calculation will result in a layer that contains a raster image and optionally a list of vector area coverages. You can export a picture of the view shed using the GM_ExportRaster function and if you chose to generate area coverage polygons those can be exported using the GM_ExportVector function.

    Let me know if I can be of further assistance.


    Global Mapper Support
  • AzularAzular Global Mapper User Posts: 3
    edited March 2009
    Thank you for the help. I managed to load the DEM file but when I'm trying to export as shapefile I get error 12. What does this mean?
    I'm using the following code to export
    iError = GM_ExportVector("E:\user\AppFiles\export.shp", _
                                           GM_VectorExportFormat_t32.GM_Export_Shapefile, _
                                           Handle, _
                                           Nothing, _
                                           GM_VectorExportFlags_t32.GM_VectorExportFlags_ExportAreas, _
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2009
    Here is a list of the error codes from the GlobalMapperInterface.h file:

    typedef uint32 GM_Error_t32; enum
    GM_Error_None = 0,

    GM_Error_InvalidLayer = 1, // The provided layer is not open
    GM_Error_InvalidParam = 2, // A parameter was invalid
    GM_Error_LoadError = 3, // Unable to load layer
    GM_Error_MultipleLayers = 4, // Multiple layers were found in the file being loaded (call GM_LoadLayerList instead)
    GM_Error_CollarSetup = 5, // Unable to automatically crop the collar
    GM_Error_DrawError = 6, // An unknown error occured drawing the layer(s)
    GM_Error_ExportError = 7, // An unknown error occured exporting the layer(s)
    GM_Error_NothingToExport = 8, // No data was available to export
    GM_Error_InvalidFormat = 9, // An invalid export format was specified
    GM_Error_RectifyError = 10, // An error occured rectifying the image
    GM_Error_NotSupported = 11, // The operation is not supported for the layer
    GM_Error_NotRegistered = 12, // No registry key was found to enable this functionality
    GM_Error_NoDataAtLocation = 13, // No data was found at the specified location
    GM_Error_OutOfMemory = 14, // Not enough memory to complete the requested operation
    GM_Error_Projection = 15, // An error occured projecting a coordinate
    GM_Error_NoProjectionSet = 16, // No view/export projection is currently set
    GM_Error_ViewShedCalc = 17, // An error occurred performing the view shed analysis
    GM_Error_OperationCanceled = 18, // The user canceled the operation
    GM_Error_TerraServerConnect = 19, // A connection to the TerraService could not be established
    GM_Error_TerraServerBadTheme = 20, // No TerraServer theme with the theme name provided could be found
    GM_Error_GenerateContours = 21, // An error occurred generating the contours
    GM_Error_NotRasterLayer = 22, // The layer provided is not a raster or elevation layer
    GM_Error_InvalidPackage = 23, // The provided handle is not a valid package
    GM_Error_InvalidFeatureIndex = 24, // There was no feature at the given index in the layer
    GM_Error_InvalidDrawStyle = 25, // The drawing style passed in is not valid
    GM_Error_InvalidSymbolName = 26, // The symbol name provided does not match any available point symbols
    GM_Error_SymbolAlreadyCreated = 27, // The symbol name specified has already been added
    GM_Error_MissingFile = 28, // The file specified could not be found
    GM_Error_GPSDataNotValid = 29, // The GPS data requested does not currently have a valid value available
    GM_Error_GPSAlreadyTracking = 30, // A GPS device is already being tracked, call GM_GPSStopTracking
    GM_Error_VolumeCalcFailed = 31, // An error occurred calculating the volume
    GM_Error_InvalidHoleIndex = 32, // The area does not have a hole at the index provided
    GM_Error_InvalidMapIndex = 33, // There is no map at the given index in the map catalog
    GM_Error_3DNotOpen = 34, // No 3D view window is currently open
    GM_Error_3DLibraryNotFound = 35, // The ExternalViewerIntf.dll library was not found
    GM_Error_3DLibraryBadInterface = 36,// The ExternalViewerIntf.dll library did not have the proper interface
    GM_Error_3DCreateError = 37, // Unexpected error creating 3D view
    GM_Error_3DSetViewError = 38, // Unexpected error setting 3D view
    GM_Error_NothingFound = 39, // No features were found within the search area
    GM_Error_SearchError = 40, // Unexpected search area
    GM_Error_LowMemory = 41, // Some data was not drawn due to low available memory
    GM_Error_NotElevationLayer = 42, // The layer provided is not an elevation layer
    GM_Error_FileAlreadyInCatalog = 43, // The provided file was already in the map catalog to which it was being added.
    GM_Error_TypeAlreadyExists = 44, // The provided type name was already used by an existing type
    GM_Error_DatumAlreadyExists = 45, // A built-in datum with the given name already exists
    GM_Error_UnknownEllipsoid = 46, // The ellipsoid name provided does not match a known ellipsoid
    GM_Error_GridError = 47, // Error generating grid from 3D vector data
    GM_Error_InvalidShaderName = 48, // The shader name provided was not found


    GM_Error_NotImplemented = 0xFFFF // The given function hasn't been implemented yet

    As you can see error 12 means that you are not registered. You need to have a license file for the SDK (either permanent or a trial one) to be able to use functionality like exporting. Contact me at for more details.


    Global Mapper Support
  • AzularAzular Global Mapper User Posts: 3
    edited March 2009
    I have download the trial version. There is a file named gmdll_regkey_.txt that contains a key. I paste that in bin folder of my application but it doesn't seems to work. What it's wrong? Is there any other way to use that key?
  • global_mapperglobal_mapper Administrator Posts: 17,238
    edited March 2009
    You are right there was a gmdll_regkey.txt file in the Global Mapper SDK download. It was an old expired temporary key and shouldn't have been there at all.

    If you contact me at I can provide you with a working trial key.


    Global Mapper Support
Sign In or Register to comment.