Jesus Loves GRASS

Technical blog about GRASS/GIS,open source geoinformatics and MAPSERVER.

Sunday, March 04, 2007

EXTENT versus SIZE in Mapserver

I am working with 3 vectorial layers and these layers are bigger than the research area (EXTENT) I have defined the extent area to be 35 30 95 60 (lower left corner, upper right corner) dd of lat/long. Still the mapserver was rendering data from outside the extent area


It took me a while to understand the reason. The problem is with the SIZE parameter, in the above pic the size was 800 500 so the area was a bit out of the EXTENT and Mapserver will not have a problem to render any data outside the EXTENT so that the image gets the proper size.

Changing the SIZE to 800 400 I get a prefect image

Let there be color!!!

I never liked the DEM of the SRTM to be in a 16bit grey scale, so I searched for a solution. Normally in GRASS you select the SRTM color rules for it, but in Mapserver I couln't find a good enough answer on how to deal with colors in DEM (it is possible to make color scales in satellite images using the band, but a BEM only has "one band").

I have found this technical blog http://www.perrygeo.net/wordpress/?p=7 that has some nice tools from DEM processing, the tools are in C++ and need the GDAL library to be compiled.

One tool is the color-relif (there are also tools to make hillshades, slopes and aspect). So I just compiled the programs, went to /usr/local/grass-6.2.1/etc/colors to get the srtm color file, which indicates the RGB values according to the altitude. The GRASS file has sometimes instead of RGB values a color name, so in the SRTM colors there was "aqua" for 0 mt altitude, so I just changed to 0 0 255 (total blue). The
final color table is something like this

-500 0 0 10
-300 0 0 20
-200 0 0 70
-100 0 0 130
-50 0 0 205
0 0 0 255
0.1 57 151 105
100 117 194 93
200 230 230 128
500 202 158 75
1000 214 187 98
2000 185 154 100
3000 220 220 220
5000 250 250 250
8850 255 255 255

1st column is altitude and the other columns the RGB values.
So the DEM that was almost totally dark in GIMP because a very nice colored map.



The program simplely creates a band2 and 3 from the original band1 and assigns a diferent color value acording to the color table. I had the SRTM file in a tiled structure, after running the program the final file was as orignally (without internal tiles)