Sign in to follow this  
Guest Horst

Problem converting a DEM file to MESH using RESAMPLE

Recommended Posts

(trying to convert CDED1 data)Hello, I'm new to the forum and relatively new to scenery design. I'll try to make my problem as clear as possible so you experienced MESH designers don't have to spend too much time rolling your eyes at my newbie mistakes.NOTE: I have updated this posting since the first submission, see bottom of post.First of all, I have started out with DEM files, I obtained these from here http://www.geobase.ca/geobase/en/data/cded1.html the specs for the files are here http://www.geobase.ca/doc/specs/pdf/GeoBas..._CDED1_v2_1.pdf but i will post header information to avaoid reading a long PDF.I have used these dem files before and therfore know they work in other programs such as 3DEM, Microdem, etc.Although at first I had tried to convert the dem files directly using "resample.exe" from the FS2004 SDK, I soon found that I needed to convert the dem files to a binary format.To do this I used "read_dem.exe" from http://dbwww.essc.psu.edu/notes/utilities.html from a command prompt I entered "read_dem.exe 092e16w.dem new092e16e.dem 092e16w.hdr" where: 092e16w.dem is the original from geobasenew092e16w.dem is the binary DEM I am creating092e16w.hdr is the header file I am creatingThe following Header was produced:DEM Header information for 092e16w.dem:Elevation array is 1201 rows by 1201 columnsTYPE A RECORD DATA092e16DEMw Base Mapping and Geomatic Services - B.C. Gov. - Victoria -12630 0.0000 4945 0.00009 BC Process code: 9DEM level code: 1Elevation pattern: regularPlanimetric reference system: GeographicReference system zone: 0Ground coordinate units: arc-secondsElevation units: metersNumber of polygon sides: 4Elevation accuracy: UnknownRows of profiles in DEM: 1Columns of profiles in DEM: 1201Spatial resolution, easting (x): 0.75 arcsecSpatial resolution, northing (y): 0.75 arcsecSpatial resolution, elevation (z): 1.00 metersMinimum elevation: 0.00 metersMaximum elevation: 1683.00 metersCCW rotation from reference: 0.000000 radiansProjection parameters: 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00 0.0000000000e+00Projection coordinates at grid corners: Northing EastingNorthwest (UL) 180000.00 -455400.00Northeast (UR) 180000.00 -454500.00Southwest (LL) 179100.00 -455400.00Southeast (LR) 179100.00 -454500.00EXTENDED A RECORD DATALargest primary contour interval: N/ASmallest primary contour interval: N/AData source date (yymm or yyyy): Not specifiedInspection/revision date: Not specifiedInspection/revision flag: Not specifiedData validation flag: Not specifiedSuspect and void area flag: Not specifiedVertical datum: local mean sea levelHorizontal datum: NAD 83Data edition: 0After converting two DEM files for the region I created the following .inf for multiple sources.[Destination] LOD = 12 DestDir = ".scenery" DestBaseFileName = "nootka" NorthLat = 50.0 SouthLat = 49.75 EastLon = -126.0 WestLon = -126.5[source] Type = MultiSource NumberOfSources = 2[source1] Type = ElevS16LSB SourceDir = "c:mapdatadem" SourceFile = "new092e16e.dem" CellType = S16LSB NullCellValue = -9999 Lat = 50.0 Lon = -126.25 NumOfCellsPerLine = 1201 NumOfLines = 1201 CellXdimensionDeg = 0.000205555556 CellYdimensionDeg = 0.000205555556 ScaleinMeters = 1.0[source2] Type = ElevS16LSB SourceDir = "c:mapdatadem" SourceFile = "new092e16w.dem" CellType = S16LSB NullCellValue = -9999 Lat = 50.0 Lon = -126.5 NumOfCellsPerLine = 1201 NumOfLines = 1201 CellXdimensionDeg = 0.000205555556 CellYdimensionDeg = 0.000205555556 ScaleinMeters = 1.0I then ran "resample.exe nootka.inf" from the command prompt and it spat out the following:Microsoft ® Terrain Mesh File (TMF) Creation Tool Version 1.0.0.4Copyright © Microsoft Corp 2001-2003. All Rights Reserved.Resample Info File: 'nootka.inf'[source] Type = 'MultiSource'[source] NumberOfSources = 2[source1] Type = 'ElevS16LSB'[source1] SourceDir = 'c:mapdatadem'[source1] SourceFile = 'new092e16e.dem'[source1] Lon = -126.250000[source1] Lat = 50.000000[source1] NumOfCellsPerLine = 1201[source1] NumOfLines = 1201[source1] CellXdimensionDeg = 0.000206[source1] CellYdimensionDeg = 0.000206[source1] ScaleInMeters = 1.000000[source1] NullCellValue = -9999.000000[source2] Type = 'ElevS16LSB'[source2] SourceDir = 'c:mapdatadem'[source2] SourceFile = 'new092e16w.dem'[source2] Lon = -126.500000[source2] Lat = 50.000000[source2] NumOfCellsPerLine = 1201[source2] NumOfLines = 1201[source2] CellXdimensionDeg = 0.000206[source2] CellYdimensionDeg = 0.000206[source2] ScaleInMeters = 1.000000[source2] NullCellValue = -9999.000000[Destination] DestDir = '.scenery'[Destination] DestBaseFileName = 'nootka'[Destination] LOD = '12'[Destination] NorthLat = 50.000000[Destination] SouthLat = 49.750000[Destination] EastLon = -126.000000[Destination] WestLon = -126.500000;:9876543210.0..10..0..0....0....210..0..0....0....10..0..0....0....3210..0.0....0..43210..0..10....0....0....0....10..0.10....0....0..0..210....0....0....0....10....0....0....0....10....0....0..0..10....0....0..0..3210....0..0....0..10....0..0..0.It then created "nootka.bgl" a 732 byte file (certainly not the BGL I was expecting).Could anyone offer any suggestions or insight as to why I would be getting this (nearly) empty file output?thank you,JustinPS: This mesh terain is for a scenery project I've been planning ofr a few years. I have 5m resolution satellite imagery for the Nootka sound region created from LANDSAT 7 grayscale bands. I know that google and other sites off this data already colourized but I mixed my own channels and got something much closer to the real colour (will submit sample in next post). I also plan to incorperate all the villages (Gold River, Tahsis, Zebellos, Kyuquot), settlement, reserves and camps. I will be making the scenery available to the public as it progresses. the full version will be available on my site greensasquatch.ca when it is done and I can find a new hosting provider.UPDATE:changed the LOD setting to 11 and the BGL compiled at 942KB (still seems small). However when I view the file with "tmfviewer.exe" I find it only converted the centres of each DEM file leaving a space between the two. I know both DEM files are adjacent thus there should be no space between them.Link to image of BLG file in viewer:http://img510.imageshack.us/img510/2302/tm...rcapture9vm.jpgLink to BGL file (on free file hosting site):http://rapidshare.de/files/9029283/nootka.bgl.html

Share this post


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

Hi,I think you've found two different quirks of resample. I wouldn't feel too bad about it, neither one is obvious and most people seem to find them fairly quickly :)First, the tiny file you got is a bug in newer versions of resample that crops up when you increase the LOD past what it thinks is a decent level. The workarounds are to decrease the LOD as you found, or to use the version of resample from the FS2000 SDKs.Second, resample splits your data into squares so that it can index it. However, it will never create a square which has any gaps; this is why you will usually lose a bit of data around the edges, or perhaps even get no data output at all. In your case, the files you've created don't quite meet in the middle, resulting in a small gap between them. This is enough for resample to throw away the entire square, which is why you're getting that large gap between the two source files.To fix this, you need to look at your source data and the values that describe it. Take the western file, which should probably go from -126.5 to -126.25 . You've given a cellwidth of 0.000205555556. -126.5 + (1201 * 0.000205555556) = -126.253127777244Your second file starts at -126.25, so that 0.003128 of a degree which isn't defined is what's causing the gap. Try using 0.0002083334 instead. That number came from this:- You need your data to cover at least 0.25 of a degree.- There are 1200 posts in that distance, the extra one is usually provided to give a little overlap.- 0.25 / 1200 = 0.00020833333333...- Rounding down to 0.0002083333 may still come up slightly short, although you've got that extra pixel which should bring you back up over 0.25 degrees, so I usually round up, in this case giving 0.002083334. Experiment with the numbers to find out which one gives you the neatest mesh though.HTH,Jim

Share this post


Link to post
Share on other sites

You, Sir, are a genius. Been going through spec files different DEM formats and checking files in differnet programs for how ever many hours its been since the original post. I came up with nothing, I never would have thought of your solution as the programs I use always fill in that gap. Thank you very much for the math lesson as well, I can actually say i understand (now). I'll now work on trying to figure out how to get FS2004 to actually use my mesh instead of the default one.thanks again,Justin

Share this post


Link to post
Share on other sites

Hello Justin,Beside Jim tips, I would like to mention some other

Share this post


Link to post
Share on other sites

Hello Horst,thank you for your kind help. I have used microdem and oziexplorer with both the landsat 7 data and the cded1 data and have not noticed significant differences in alignment when overlaid. I always assumed the difference in the datasets was so minor as not to make a difference.since my last message I have generated a BGL mesh file (LOD11) from the CDED data and imported it into flight sim, the results were amazing, the mountains looked exactly as i had remembered them not counting the missing texture. I have not, however had any success in fiding a method of converting my imagery to the same sample size and then to scenery files. When the program asks me for the Lat and Long I would imagine I could give the NAD83 lat and long as they were WGS84 and not expect too much difficulty ( I have done this before in other programs with reasonable success).I suppose right now I am looking for a method of creating LOD11 scenery from the landsat7 imagery. Tried using resample via the niagra sample method but it took a few GB and produced TGA files of greater pixel resoution than the 15m source file.Any suggestions, it seems I'm lost once again, I just want to see some texture on my mountains even if it is skewed or off, then work on making it better afterwards.thanks,Justin

Share this post


Link to post
Share on other sites

Hello Justin,yes, it is nonsens to think between these datums for a game (sorry for my post yesterday) for this data.But think about the relation between the LOD Dem and the TMVL in the fs9.cfg (unfortunately: world wide), and the not need data amount your machine have to calculate.The images are using mip levels and not LOD.For the landsat.I remember to use this WMS server once:http://geodiscover.cgdi.ca/gdp/search?acti...85&entryLang=enThere is 1m ortho (B/W) available.For your area, I am not sure: I can today request only the overview.135542.jpgMaybe ask the guys there?I used the data once (for BC), to make me scenery, but I do not know, where you can get the source data today. And the license and copyright terms, when you want to publish it (I never did)It was funny to use it, and colour some glaciers.135543.jpg135544.jpgSome kind of partial photo.But instead of using photo (only for parts), I always try to use the landclass system.Because, I do not like to add autogen later and my machine can not handle it.Not helpful for your current landsat approach, but have a look, if you can get better data (for free?)Kind regardsHorst

Share this post


Link to post
Share on other sites

Horst,thanks again for another informative e-mail. I haven't been on the computer much and haven't been able to do much looking into the 1m ortho data but from what i can find they want $200 per 1:25K sheet. I'll keep looking though as when I first found the landsat imagery it was also a pay for data service until I noticed geogratis. I have tried converting some image data I have, this link:http://img197.imageshack.us/img197/6003/go...rdinates5qh.jpg shows the file to which I refer. I created it in mapedit a program which rectified the image so the sides are now parallel to latitude and longitude.Using the freeware program photoscenery maker I converted to a scenery file (nowhere did it allow me to select LOD).However the scenery had much less detail than the source image and actually caused the mesh to reduce in complexity. Perhaps you could suggest a method of converting this directly to LOD 11?thanks again,JustinPS: please excuse the poor quality of the image, it has lost much detail in the various conversions and compressions. The map co-ordinates are in the bottom right of the image if you wish to use it yourself.

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