Giter Club home page Giter Club logo

heightmap's Introduction

Proggy to read heightmap data from the file srtm_ramp2.world.86400x43200.bin and write the wanted area of the world to one 16-bit grayscale png heightmap image and one texture rgb png image. The wanted area is specified in latitudes/longitudes.

PREPARATION

Before running the program the first time, the files:

  • srtm_ramp2.world.86400x43200.bin.gz
  • world.topo.bathy.200410.3x21600x10800.png

needs to be downloaded into the datafiles directory. These files are part of the NASA Blue Marble Next Generation project and can be found at:

Webpage: http://visibleearth.nasa.gov/view.php?id=73934
Mirror: ftp://neo.sci.gsfc.nasa.gov/bluemarble/bmng/

The script get_datafiles.sh automatically downloads these files and unpacks the gzipped srtm file.

Checkout the program and build it:

git clone git://github.com/AlbertVeli/heightmap.git
cd heightmap
make

The make command will build the hm program and run the get_datafiles.sh script to download the files and unzip the srtm file.

DEPENDENCIES

Ubuntu (apt-get install):

  • build-essential
  • libpng-dev
  • libtiff-dev

Gentoo (emerge -av):

  • media-libs/libpng
  • media-libs/tiff

Macports (port install):

  • libpng
  • tiff

MinGW (install manually from gnuwin32.sourceforge.net):

  • LibPng
  • LibTiff

You also need gunzip from the package gzip to unzip the srtm datafile. It is installed by default in all of the above.

USAGE

hm [OPTIONS] <latitude> <longitude> <lat. span> <long. span> <basename>

Use decimal fractions for latitude/longitude/spans.

latitude (North/South) - in range 90 (° N) to -90 (° S)
longitude (West/East) - in range -180 (° W) to 180 (° E)
latitude span - height of the wanted area in degrees
longitude span - width of the wanted area in degrees
basename - common beginning of the two filenames to save output to

OPTIONS

-h <FILE> - Datafile for heightmap instead of default
-t <FILE> - Datafile for texture instead of default
-v        - Verbose output

EXAMPLE

To generate images scandinavia_heightmap.png and scandinavia_texture.png for the Scandinavia area (74° N, 3° E, span 19°, 27°), run:

./hm 74 3 19 27 scandinavia

Use a map, terrestrial globe, google maps or other web service to figure out latitudes/longitudes. In google maps, zoom into an area and copy the URL (click on the share button). It could look something like:

https://maps.google.com/?ll=53.91081,-5.50415&spn=7.374845,13.557129

Here the center is at 53.91081° N, 5.50415° W and the height/width span of the map in degrees are 7.374845°, 13.557129°. To get to the upper left corner, move one half span in each direction.

The arguments to cut out the corresponding area with this program:

53.91081 + 7.374845/2  ; North (up) half height span
-5.50415 - 13.557129/2 ; West (left) half width span
7.374845               ; Height span
13.557129              ; Width span

If you calculate the coordinates the command line will be:

./hm 57.5982325 -12.2827145 7.374845 13.557129 ireland

Image rendered in Blender simulating a 40m sea level rise over Ireland using the exact command line shown above. See instruction video below for information on how to render the image in Blender.

ireland

ELEVATION DATAFILE

In the heightmap data each pixel represent average height (meters above sea) of an area with a signed 16-bit integer (big endian).

Dimension of the srtm data is 86400x43200. Upper left pixel is at 90° N, 180° W and bottom right is at is at 90° S, 180° E. Each pixel is thus 360/86400° = 15 arcseconds ~= 500m (at the equator). 1 arcsecond = 1/3600:th of a degree. Longitudes are distorted towards the poles while latitudes are roughly 500m per pixel through the whole range.

INSTRUCTION VIDEO

This video shows how to compile and use the program. It also shows how the generated heightmap and texture files can be rendered with Blender.

http://www.youtube.com/watch?v=1nKxmyudoLI

LICENSE

~~=) All Rights Reversed - No Rights Reserved (=~~

Prickle-Prickle, the 9th day of Chaos in the YOLD 3179

Albert Veli

heightmap's People

Contributors

albertveli avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

heightmap's Issues

Generated heightmap/texture dimensions off by one

Width/Height is 1 pixel too big.

Example. In heightmap each degree should be 86400/360 = 240 pixels. The example cmdline:

./hm 74 3 19 27 scandinavia

should generate a 27_240 x 19_240 = 6480 x 4560 heightmap image, but the generated image is 6481 x 4561 pixels.

Extract texture data from tiles

Tiles are numbered as:

  • A1 - 90N, 180W to 0N, 90W
  • B1 - 90N, 90W to 0N, 0W
  • C1 - 90N, 0W to 0N, 90E
  • D1 - 90N, 90E to 0N, 180E
  • A2 - 0N, 180W to 90S, 90W
  • B2 - 0N, 90W to 90S, 0W
  • C2 - 0N, 0W to 90S, 90E
  • D2 - 0N, 90E to 90S, 180E

subdomains

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.