HTMLMAP driver

From GRASS-Wiki
Jump to: navigation, search

This page will describe an example of using GRASS 6's HTMLMAP driver to create a clickable web page based on vector data.

Specifically, we'll create a page with a map showing all of the local Transverse Mercator EPSG codes, and clicking on the map will show you the code and its parameters.

There's a little prep work needed to extract the EPSG codes into a GRASS vector map. The details of doing this are not important to the overall example.

Prep work

  • Parse the epsg file for NZGD2000 projections and make into a flat file, with lat_0 and lon_0 extracted:
grep -A1 NZGD2000 /usr/share/proj/epsg | grep -v '^--$' | \
  grep -B1 '+lat_0' | grep -v '^--$' | \
  sed -e 's| / \([^ ]*\) \([^ ]*\)| / \1^\2|' \
      -e 's| / \([^ ]*\) \([^ ]*\)| / \1^\2|' \
      -e 's| / \([^ ]*\) \([^ ]*\)| / \1^\2|' \
      -e 's| / \([^ ]*\) \([^ ]*\)| / \1^\2|' | \
  tr '\n' ' ' | tr '#' '\n' | \
  sed -e 's/^ //' -e 's/  <> $//' -e 's/ \/ / /' \
      -e 's/ /|/' -e 's/ /|/' -e 's/ /|/' \
      -e 's/|</|/' -e 's/>|/|/' -e 's/\^/ /g' \
  > nzgd2k_epsg.dat

cat nzgd2k_epsg.dat | sed -e 's/.*+lat_0=//' -e 's/ .*//' \
  > lat0s.dat

cat nzgd2k_epsg.dat | sed -e 's/.*+lon_0=//' -e 's/ .*//' \
  > lon0s.dat

paste -d'|' nzgd2k_epsg.dat lat0s.dat lon0s.dat > nzgd2k_epsg_xy.dat


  • Some of these projections have an undefined (or 0 value) for +lat_0. To make things easy we can specify a nearby value by hand:
cut -d'|' -f2,5 nzgd2k_epsg_xy.dat | grep '|0$' | cut -f1 -d'|'

Auckland Islands TM 2000 (50.75 degrees S)
Campbell Island TM 2000 (52.5 degrees S)
Antipodes Islands TM 2000 (49.75 degrees S)
Raoul Island TM 2000 (29.25 degrees S)
Chatham Island Circuit 2000 (44 degrees S)


  • Then we can import it into a GRASS lat/lon WGS84 location:
v.in.ascii in=nzgd2k_epsg_xy.dat \
  out=local_circuits_nzgd2k x=6 y=5 \
  columns='datum varchar(8), projection varchar(40), epsg_code integer, proj4_str varchar(255), lat_0 double, lon_0 double'

Creating a Voronoi diagram

  • Create a LCC location to work in (NZCS2000, epsg code <3851>)
  • Use the v.proj module to bring in the projection center points:
v.proj in=local_circuits_nzgd2k loc=ll_wgs84 mapset=nz
  • Set the bounding region for the diagram with the g.region module:
g.region north=9380000 south=4600000 east=5960000 west=470000 res=10000
v.voronoi in=local_circuits_nzgd2k out=local_circuits_nzgd2k_voronoi
  • Create a 150km buffer around the points:
v.buffer in=local_circuits_nzgd2k out=local_circuits_nzgd2k_buf150km dist=150000
As these are all tmerc, maybe we should use the v.buffer angle= option to allow further use north/south?
  • Overlay the Voronoi diagram with the buffer:
v.overlay ain=local_circuits_nzgd2k_voronoi bin=local_circuits_nzgd2k_buf150km \
   out=local_circuits_nzgd2k_voronoi_buf150km op=and

Rendering

  • ...
g.manual htmlmapdriver


d.save -o > render_commands.sh
d.mon start=HTMLMAP
. render_commands.sh
d.mon stop=HTMLMAP


  • TBC ...