htmldriver(1)
π HTML DISPLAY DRIVER π
okay bestie, buckle up, this is htmldriver(1) β the GRASS GIS User's Manual page for the HTML display driver, and it's literally the girl that makes HTML image maps for you. β¨
It's an HTML display driver that creates HTML image maps. That's the whole vibe. π
πΈ DESCRIPTION πΈ
So the HTML driver lets you generate HTML image maps for area vector data. HTML image maps get used alongside images to give you unique URL targets for different portions of an image β like, different clicky zones, yk? π₯ And the HTML driver can create both:
- client-side image maps embedded right into HTML files, or
- server-side image maps used by web server software.
Polygons can have at most 100 vertices β and no, that's not the driver being dramatic, that limit is imposed by HTML image map formats themselves (see GRASS_RENDER_HTMLMAXPOINTS below). π The driver will attempt to trim polygons that have more than 100 vertices by removing vertices with the least amount of angle to the next vertice. Also, any polygon that is entirely bounded by another polygon will be discarded. Gone. Bye. π
Text written to the driver before polygons is used as the HREF tag for all subsequent polygons written. So all polygons that exist in a vector map will have the same HREF tag. Periodt.
The only GRASS display commands that should be used with this driver are:
d.textβ pass href information for resulting image maps.d.vectβ draw polygons from a vector map.
β οΈ Note the "only" up there. That's not a suggestion, bestie.
β¨ USAGE β¨
π¦ Environment variables
The HTML driver can be enabled by setting the GRASS_RENDER_IMMEDIATE variable, eg.
export GRASS_RENDER_IMMEDIATE=html
Several environment variables affect the operation of the HTML driver:
GRASS_RENDER_WIDTH=xxxβ the width of the image map (default is640).GRASS_RENDER_HEIGHT=yyyβ the height of the image map (default is480).GRASS_RENDER_HTMLTYPE=typeβ type of image map to create (default isCLIENT):CLIENTβ Netscape/IE client-side image map (NAME="map").APACHEβ Apache/NCSA server-side image map.RAWβ Raw url and polygon vertices (`url x1 y1 x2 y2 .....), suitable for conversion to CERN server format, or any other format with user supplied conversion program.
GRASS_RENDER_FILE=filenameβ specifies the resulting file to store the html image map, default ishtmlmap. Files without absolute path names are written in the current directory where the driver was started. Any existing file of the same name is overwritten without warning. πGRASS_RENDER_HTMLMINDIST=nβ specifies the minimum distance in pixels that a point must change from the previous point to keep in the list of vertices for a polygon. The default is2, which means that a point's x and y difference from the previous point must change by a number of pixels greater than this value. This parameter helps to eliminate closely spaced points.GRASS_RENDER_HTMLMINBBOX=nβ specifies the minimum bounding box dimensions to record a polygon as a clickable area. The default is2, which means that a polygon with a bounding box of less than this value is not included. This parameter helps to eliminate polygons than are a point or line.GRASS_RENDER_HTMLMAXPOINTS=nβ specifies the maximum number of vertices included in a polygon's clickable area. The default is99. Some browsers can only accommodate polygons of 100 vertices or less. The HTMLMAP driver automatically ensures that a polygon is closed by making the last point the same as the first point.
π Example
Start up the driver
g.region vector=zipcodes_wake
d.mon start=html
Display text strings (HREF's) and polygons
echo "https://en.wikipedia.org/wiki/Raleigh,_North_Carolina" | d.text
d.vect map=zipcodes_wake where="ZIPNAME = βRALEIGHβ"
echo "https://en.wikipedia.org/wiki/Cary,_North_Carolina" | d.text
d.vect map=zipcodes_wake where="ZIPNAME = βCARYβ" fill_color=180:200:210
Stop the driver once all polygon have been displayed. This will create a file named 'htmlmap' in your current directory:
d.mon stop=html
You will also want to create an image for your image map. Use the PNG driver and other utilities to create .gif or .jpg files. The following example is somewhat out of date and refers to options available in GRASS 5. π¬
# using previous GRASS_RENDER_WIDTH & GRASS_RENDER_HEIGHT
d.mon start=png
d.rast map=terrain
d.vect map=area51 fillcolor=white linecolor=blue
d.vect map=roswell fillcolor=yellow linecolor=blue
d.vect map=states color=green
d.vect map=roads color=black
d.mon stop=png
# make the region the same as the newly created cell for ppm export
g.region save=saved.reg
g.region raster=D_cell
r.out.ppm -q input=D_cell output=alien.ppm
# use the netpbm utilities to create a gif (quantize if needed)
ppmquant 128 <alien.ppm | ppmtogif >alien.gif
# assemble some html with the image and the image map
echo '<html><body><img src="alien.gif" usemap="#map">' >alien.html
cat htmlmap >>alien.html
echo '</body></html>' >>alien.html
# donβt forget to reset your region
g.region region=saved.reg
# take a look and test it out
netscape file:`pwd`/alien.html &
π NOTES π
HTML was adapted from the CELL driver in GRASS 4.3. Point-in-polygon test code was lifted from Randolph Franklin's web page, see
http://www.ecse.rpi.edu/Homepages/wrf/http://www.ecse.rpi.edu/Homepages/wrf/research/geom/pnpoly.html
If you create an HTML file with two or more images and image maps, you will need to edit the map names. The HTML driver creates its map with the name map. A small sed script can easily change the map name:
sed -e βs/NAME="map"/NAME="foomap"/β < htmlmap > foomap.html
π SEE ALSO π
Cairo driver, PNG driver, HTML driver, variables
d.rast, d.vect, d.mon, d.erase, d.redraw
π AUTHOR π
Glynn Clements
β SOURCE CODE β
Available at: HTML DISPLAY DRIVER source code (history)
Accessed: Saturday Jan 17 05:39:55 2026
Main index | Topics index | Keywords index | Graphical index | Full index
Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual
okay that's the whole page, you ate it, and this little cutie is signed off as GRASS 8.4.2 / htmldriver(1) π«Άβ¨ go make some image maps bestie, iykyk π
πΈ
π¦ where this page comes from
- fedora 44: grass 8.4.2-4.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms