Sign in to follow this  
tstiegler

Newbie, How to extract altitude data from bgl file

Recommended Posts

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

Share this post


Link to post
Share on other sites
Help AVSIM continue to serve you!
Please donate today!

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

>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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this