Skip to content
View in the app

A better way to browse. Learn more.

The AVSIM Community

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Newbie, How to extract altitude data from bgl file

Featured Replies

I have a Mesh bgl file that I want to extract the altitude info from for known latitude/longitude coordinates.I am writing a program to color black and white images, I currently choose the best color to color a greyscale pixel by using its luminance and local texture (neighbourhood pixel statistics), what I want to experiment with is a further refining by limiting colors based on altitude, the color image that the program learns from is georeferenced so when I sample the color image I want to create an altitude parameter to aid the color selection process.Can anybody help me, I am coding in VB.NetDavid

  • Commercial Member

Hi David,others (Jim?) may be better suited to give you a more technical answer but, in general, compiled .bgl files are copyrighted to the respective authors (or Microsoft) and thus a bit of a touchy subject for decoding. However, Jim's LWMViewer uses an internal decoder for mesh files, for similar reasons as what you seem to have in mind; since his utility doesn't allow to write the "cracked" code I'd consider that a legitimate use. Alternatively, since most free or commercial mesh files use source data that are available for free on the Internet, you could download the original data instead and use those for your shading algorithms. Cheers, Holger

Hi.Downloading data is probably the cleanest method. If you don't want to do that, you could use LWMViewer (and Export Bitmap) or TMFViewer (and screenshot) to get rough elevation data. The first is probably better because it is georeferenced.If you load a suitable BGL and choose no blending and no lightsourcing in colour display mode, you should get a useful elevation bitmap. I can give you details of the height-to-palette mappings that I use so you can work out what the elevation bands are.I can't give you information on how to read the files directly though - sorry!Cheers,Jim

Thank you for the responses, I have actually found the data of the bgl in an ASC file format, which is a text format using data as int16, I just need to work out how to open and read the text file contents and read the altitude data when passing a Latitude / Longitude reference. Thanks again for your help.David

Hi.If you've already got the elevation data in text format, it could be laid out in almost any way imaginable. There should be some kind of description of the file format at wherever it was you downloaded it from.Basically you need the lat/long of the first value in the file, the width and height of the data and the cell width/height values, which will tell you how much area each value covers. Some basic arithmetic should then convert a lat/long coord to a pixel coord; you can use this to offset into the data area of the file. It will probably be easier to read the entire file into a memory-based binary array than to repeatedly scan the text file for a particular value.Then,x_offset = (target_long - file_long) / cellwidth;y_offset = (file_lat - target_lat) / cellheight;if (x_offset >= 0 && x_offset < file_width && y_offset >= 0 && y_offset < hile_height) { v = Array[((int)y_offset) * file_width + (int)x_offset];} else { // value not present in data}Cheers,Jim

  • 4 months later...
  • Author

Hi Jim,did I understand you right, that the BGL format of mesh files is copyright protected so that I'm not allowed to read any data from it? I'm about to develop a free addon that needs elevation informations for a given lat/lon position directly from a BGL file. I'm not looking for a ready-to-use algorithm but only for the file format.I'm a bit puzzled because the format of other kinds of BGL files is well known to the community.Regards from Germany, Tom.

I believe it was Holger talking about copyright, not Jim. If you read the EULA, you can see for yourself the rights given for the software.That being said, I don't see any problem reading the data. From what you said, you are not intending to modify the data in any way but use the data information to provide some form of readout.If reading the existing data was a problem, many addons would be in violation of the EULA.W. Sieffert

Bill Sieffert

  • Author

>That being said, I don't see any problem reading the data. >From what you said, you are not intending to modify the data>in any way but use the data information to provide some form>of readout.Correct, that's exactly what I'm intended to do. So does anybody has any information about the format mesh data is stored in BGL files?Thanks a lot, Tom.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.