[Gdal-dev] read prj & metadata from .html file?

Matt Wilkie matt.wilkie at gov.yk.ca
Tue Feb 1 19:39:07 EST 2005


> I half expected that would be your stance. I was hoping that someone 
> would chime in with a script they'd already built. :) Guess I'll try and 
> figure out how to do it myself.

Okay here is a quick and dirty bash script which works about 80% of the 
time -- on the DRGs I've tested (only about 100!). It fails where the 
structure of the html file is slightly different from the norm, for 
example an extra space before the Zone number or something.

The only parameter it grabs from the metadata html file is the UTM Zone 
number.

Process-list.txt prepared ahead of time and looks like:
	c70141a1
	c70141a1
	c70144a1
	c51178c1
where each number corresponds to the tif filename (c51178c1.tif)

#!/bin/sh
for drg in `<process-list`; do
     # get the UTM Zone number
     DRGZONE=`grep Zone $drg.html | sed -e 's/<.*> *//' -`
     #translate and set prj info
     gdal_translate -a_srs "+proj=utm +datum=nad27 +zone=$DRGZONE" -co 
"COMPRESS=PACKBITS" $drg.tif out/$drg.tif
     # clean up
     DRGZONE=
     done
echo.
echo Watch for Zones which look out of range:
echo.
for img in *.tif; do
     gdalinfo $img |grep -i zone
     done
#/end of script/


cheers,

-- 
matt wilkie
--------------------------------------------
Geographic Information,
Information Management and Technology,
Yukon Department of Environment
10 Burns Road * Whitehorse, Yukon * Y1A 4Y9
867-667-8133 Tel * 867-393-7003 Fax
--------------------------------------------




More information about the Gdal-dev mailing list