Friday, October 15, 2010

How to visualize Philippine GIS data in OpenSim

Here is how I was able to terraform the OpenSim server using elevation data for the Philippines.  I will document the procedure here.

**Software needed**

1. VTBuilder http://www.vterrain.org/Doc/VTBuilder/overview.html (Windows)
http://vterrain.org/dist/VTBuilder_090826.exe
(Note: The vtbuilder listed here only works with Windows. But the VTP software suite can be compiled in Linux. I'll post on that later on.)

2. L3DT Standard Edition http://www.bundysoft.com/L3DT/downloads/standard.php
(Note: L3DT can run on Wine in Ubuntu)

3. The Gimp
4. Opensim Server
5. Hippo Opensim viewer or Imprudence viewer
6. Gimp Terrain http://dominodesigns.info/project/gimpterrain
7. Blank SL raw terrain file - available with terrainerizer script http://stringofbits.net/terrainerizer/

**Elevation data**

1. DTED Philippines GIS Data Depot http://data.geocomm.com/catalog/RP/datalist.html
2. ETOPO1 Global Relief Model  www.ngdc.noaa.gov/mgg/global/global.html

**Procedure**

//Preparing geospatial data for 3D visualization//

DTED data in VTBuilder


  1. Import elevation data in VTBuilder
  2. Use the Area Tool to select the Philippines
  3. In the Area Tool menu open the Match Area and Tiling to Layer dialog
  4. Set Tile LOD0 Size:  to 256
  5. Now open the Area Tool->Merge and Resample Elevation dialog
  6. Select To file and fill in the path to filename of .bt file
  7. Click ok to write the .bt file
  8. Close VTBuilder

ETOPO data in VTBuilder



//Preparing the PNG heightfield map//

L3DT Screenshot

  1. Open L3DT and import the .bt file
  2. Calculate the other maps (I found the water map useful for masking sea level elevation)
  3. Clip unknown data via Operations→Heightfield→Clip heightfield. Set to  Clip below and To height to something like -100.  Unknown data will result into an abyss in OpenSim where the avatar may fall endlessly until it is regenerated in the home position.
  4. Export heightfield map, and for the DTED elevation data, export the water map as .png files.  These maps should have a size of 2048x2048 pixels.
  5. Close L3DT


//Preparing the SL raw files//

//Additional image editing for DTED files//

The DTED elevation data had sea level as the lowest elevation.  This results in the entire region being dry land and no ocean.  I needed to lower the sea level so that there will be oceans in OpenSim.  To do this I turned the water map into a mask in the Gimp.
  1. Open the water map .png file in the Gimp.
  2. Color select ocean.
  3. Create new layer with alpha.
  4. Copy and paste color selected ocean.
  5. Bucket fill with black (html notation 000000)
  6. Delete the original water map layer
  7. Open the heightfield map
  8. Copy and past the mask over the heightfield map
  9. Save as .png file
//Tiling the image (The pro version of L3DT can do this automatically)//
  1. Set Edit->Preferences->Default Grid->Spacing to 256 pixels height and width
  2. You'll need to restart Gimp for the change to take effect
  3. Open the heightfield .png image in Gimp.
  4. Enable the following
  5. View->Show Grid
  6. View->Show Guides
  7. View->Snap to Guides
  8. View->Snap to Grid


The 256x256 grid should be displayed.  There will be 8x8 tiles.  Pull out guidelines from the ruler and match them exactly to the gridlines.

Then Image->Transform->Guillotine. Gimp will open 64 windows of each tile.  You'll have to save each file.  The produced DTED tiles for my sample is shown below:



//Creating the SL raw files//

Install the Gimp Terrain plugin by copying the file_slraw.py file to your Gimp plug-ins directory.
Open the blank.raw file that comes with terrainerizer.

   1. Open your blank terrain file (blank.raw) and the heightmap in the Gimp.
   2. Using the Rectangle Select tool, select a 256×256 pixel section of the heightmap, starting in the upper-left corner.
   3. Click Edit -> Copy
   4. Select the terrain file and make sure the Height layer is selected.


   5. Click Edit -> Paste. You should see the section of the heightmap you copied appear as a floating layer.
   6. Click Layer -> Anchor Layer. The Height layer should now look like the copied portion of the heightmap.
   7. Click File -> Save As and save this file as a new file with the .raw extension.

Now, repeat this process for every 256×256 pixel section in your original heightmap."

Close The Gimp.


//Preparing the adjacent multiple region in OpenSim//


In the OpenSim server console issue these commands for every region

create region RegionName

It will ask for some information, the following are important.

  • location
  • port address
  • master avatar firstname, lastname and password


The map above list the location (in red) and port numbers (in blue) for each Etopo tile:


It grows eastward and northward, as the reference increases. e.g.

  • x, y
  • 1000, 1000 - origin region
  • 1000, 1001 - north
  • 1001, 1000 - east



//Uploading the raw terrain files to OpenSim//

Issue the following commands in the OpenSim server console

change region RegionName
terrain load /path/to/xxx.raw
terrain multiply 0.2
terrain elevate 18.75
terrain bake
terrain save xxx.raw

0.2 and 18.75 are numbers for the DTED data.  The ETOPO data required terrain lower 164.5 and there was no need to multiply it.
Saving the terrain makes sure all the modifications are in the raw files.

//Editing terrain in OpenSim//

This is not a 2d drawing in OpenSim but the generated Philippine map based on the data.


Run the Hippo Openmetaverse viewer (or Imprudence viewer).
View the terrain.  Fly around.
I've noticed a problem with sea level land like Central Luzon and Manila which are flooded.  (How do they keep these places dry? dikes?).  There are also problems with inland lakes like Taal lake and Lake Lanao.  These are above sea level and will appear dry.  I would probably need prim water for these lakes.

Comparison of ETOPO and DTED data visualization in OpenSim

DTED Laguna
ETOPO Laguna
DTED Corregidor Island
ETOPO Corregidor Island


In my opinion the DTED data is best for land above water, while the ETOPO data is best for undersea land. Rivers are not seen in the ETOPO data.
The DTED data is very rough compared to the Etopo data.

To edit the terrain, click on Build and then Terrain (Bulldozer icon).  Lower, raise smooth whatever needs editing.  Remember you can always reload the raw data in the server if things get too ugly.

OpenSim as a visualization tool for GIS data will not only be useful for teaching geography at a distance but may also be useful for GIS training and geology.



**References**

Amante, C. and B. W. Eakins, ETOPO1 1 Arc-Minute Global Relief Model: Procedures, Data Sources and Analysis. NOAA Technical Memorandum NESDIS NGDC-24, 19 pp, March 2009. Available at http://www.ngdc.noaa.gov/mgg/global/global.html

Are these data and images copyrighted?
No, all of our data and images are in the public domain, unless specifically marked otherwise - with the notable exception of trademarks, logos, and trade names such as the NOAA emblem and the Department of Commerce seal which are the property of the U.S. Government and are trademarks of the Commerce Department and require permission for use. All other images, and data, are available for your use. We would appreciate a link/credit/byline, as appropriate. For example:

    "Computerized digital images and associated databases are available from the National Geophysical Data Center, National Oceanic and Atmospheric Administration, U.S. Department of Commerce, http://www.ngdc.noaa.gov/."

We also ask that you please cite the original data contributors and sources of funding when you use data from NGDC. As required by 17 U.S.C. 403, third parties producing copyrighted works consisting predominantly of the material produced by U.S. government agencies must provide notice with such work(s) identifying the U.S. Government material incorporated and stating that such material is not subject to copyright protection.

For more information, please see the NGDC disclaimer and copyright notice. http://www.ngdc.noaa.gov/ngdcinfo/privacy.html#disclaimer

http://www.ngdc.noaa.gov/mgg/faq.html


GIS Data Depot http://data.geocomm.com/catalog/RP/datalist.html
All of the data available via the GIS Data Depot is free of a copyright.

L3DT Standard Edition
L3DT Standard is the freely available general-use version of L3DT.

VTBuilder
This software is entirely free to use and redistribute, with this license. http://www.vterrain.org/Doc/VTBuilder/license.txt


Balthazar. Large 3D Terrain.  In B's World [Blog]. http://balthazarsin.blogspot.com/2007/09/large-3d-terrain.html.

Balthazar. Digital Terrain Elevation Data. In B's World [Blog]. http://balthazarsin.blogspot.com/2007/09/digital-terrain-elevation-data.html

Using L3DT. In OpenSim wiki. http://opensimulator.org/wiki/Using_L3DT

Wiggins, P. (2009, September 8). Tutorial: Creating OpenSim terrain with Blender. In A Random String of Bits [Blog]. http://stringofbits.net/2009/09/tutorial-creating-opensim-terrain-with-blender/

Marama, D. (2009, July 28). Second Life Terrain Import and Export for The Gimp. http://dominodesigns.info/project/gimpterrain

No comments:

 
Creative Commons License
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License.