[GRASS-SVN] r59296 - grass-addons/grass6/raster/r.in.ign

svn_grass at osgeo.org svn_grass at osgeo.org
Sun Mar 23 10:08:17 PDT 2014


Author: vincent
Date: 2014-03-23 10:08:17 -0700 (Sun, 23 Mar 2014)
New Revision: 59296

Modified:
   grass-addons/grass6/raster/r.in.ign/description.html
   grass-addons/grass6/raster/r.in.ign/r.in.ign
Log:
changes made to handle png tiles format. Minor changes to image groups cleaning

Modified: grass-addons/grass6/raster/r.in.ign/description.html
===================================================================
--- grass-addons/grass6/raster/r.in.ign/description.html	2014-03-23 14:18:00 UTC (rev 59295)
+++ grass-addons/grass6/raster/r.in.ign/description.html	2014-03-23 17:08:17 UTC (rev 59296)
@@ -1,7 +1,59 @@
-<h2>DESCRIPTION</h2>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<title>GRASS GIS manual: r.in.ign</title>
+<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+<link rel="stylesheet" href="grassdocs.css" type="text/css">
+</head>
+<body bgcolor="white">
 
-<em>r.in.ign</em> imports raster data from <a href="http://api.ign.fr">IGN WMTS service</A>. Available layers depend upon the user's contract.
+<img src="grass_logo.png" alt="GRASS logo"><hr align=center size=6 noshade>
 
+<h2>NAME</h2>
+<em><b>r.in.ign</b></em>  - this module imports raster data from <a href="http://api.ign.fr">IGN WMTS service</A>. Available layers depend upon the user's contract.
+
+<h2>KEYWORDS</h2>
+raster, import, wms, wmts, ign
+<h2>SYNOPSIS</h2>
+<b>r.in.ign</b><br>
+<b>r.in.ign help</b><br>
+<b>r.in.ign</b> [-<b>cm</b>] <b>apikey</b>=<em>string</em> <b>user</b>=<em>string</em> <b>password</b>=<em>string</em> <b>wmtslayer</b>=<em>string</em> <b>tiletype</b>=<em>string</em> <b>output</b>=<em>string</em>  [--<b>overwrite</b>]  [--<b>verbose</b>]  [--<b>quiet</b>] 
+
+<h3>FLAGS</h3>
+<DL>
+<DT><b>-c</b></DT>
+<DD>Get capabilities</DD>
+<DT><b>-m</b></DT>
+<DD>output 3 separate-band rasters rather than a composite RGB raster </DD>
+<DT><b>--overwrite</b></DT>
+<DD>Allow output files to overwrite existing file</DD>
+<DT><b>--verbose</b></DT>
+<DD>Verbose module output</DD>
+<DT><b>--quiet</b></DT>
+<DD>Quiet module output</DD>
+</DL>
+
+<h3>PARAMETERS</h3>
+<DL>
+<DT><b>apikey</b>=<em>string</em> [<b>required</b>]</DT>
+<DD>personal apiKey</DD>
+
+<DT><b>user</b>=<em>string</em> [<b>required</b>]</DT>
+<DD>Username for server connection</DD>
+
+<DT><b>password</b>=<em>string</em> [<b>required</b>]</DT>
+<DD>Password for server connection</DD>
+
+<DT><b>wmtslayer</b>=<em>string</em></DT>
+<DD>Layer to request from WMS server</DD>
+
+<DT><b>tiletype</b>=<em>string</em></DT>
+<DD>tile image format</DD>
+
+<DT><b>output</b>=<em>string</em></DT>
+<DD>Name for output raster map</DD>
+
+</DL>
 <h2>NOTES</h2>
 <p><em>r.in.ign</em> lets you query a dataset via a contract. Beware the conditions that come with it and terms of use that apply to data.</p><p>It is only a transitory module aiming at allowing french wmts support for GRASS 6.4 version (r.in.wms module fails at requesting this service, and r.in.wms.py Add-On does not correctly handle french projection systems (which operate nadgrid-based datum shifts). It is quite rough but easily adaptable to one's personnal needs.</p><p>
 Connecting to the WMTS streams of Géoportail is not straight, in cause a restricted access protected by a personal apiKey that comes with your contract. See practical details concerning registration on the <a href="http://api.ign.fr">official website</A>.
@@ -11,24 +63,29 @@
 <h2>EXAMPLE</h2>
 
 This command returns the list of available layers for contract pi3cawp5p883ql4bdk3bhert owned by vincent :
-
-<div class="code"><pre>
+<p><tt> 
 r.in.ign -c apikey=pi3cawp5p883ql4bdk3bhert user=vincent password=******
-</pre></div>
+</tt></p>
 
-Import orthoimagery from IGN wmts server, to a composite raster map <em>orthoign</em>:
+Import orthoimagery from IGN wmts server, to 3 raster bands <em>orthoign.red</em>, <em>orthoign.green</em>, <em>orthoign.blue</em>:
+<p><tt> 
+r.in.ign -m apikey=pi3cawp5p883ql4bdk3bhert user=vincent password=******  wmtslayer=ORTHOIMAGERY.ORTHOPHOTOS tiletype=jpeg output=orthoign
+</tt></p>
 
-<div class="code"><pre>
-r.in.ign apikey=pi3cawp5p883ql4bdk3bhert user=vincent password=******  wmtslayer=ORTHOIMAGERY.ORTHOPHOTOS output=orthoign
-</pre></div>
+Import cadastral parcels from IGN wmts server to a raster <em>parcels</em>:
+<p><tt> 
+r.in.ign apikey=pi3cawp5p883ql4bdk3bhert user=vincent password=******  wmtslayer=CADASTRALPARCELS.PARCELS tiletype=png output=parcels
+</tt></p>
 
 <h2>SEE ALSO</h2>
 
-<em><a href="r.in.wms.html">r.in.wms</a></em>
+<em><a href="http://grass.osgeo.org/grass64/manuals/html64_user/r.in.wms.html">r.in.wms</a></em>
 
 <h2>AUTHOR</h2>
 
 Vincent Bain, Toraval, France
 
-<p>
-<i>Last changed: $Date: 2013-02-14$</i>
+<p><i>Last changed: $Date: 2014-03-23$</i>
+
+</body>
+</html>

Modified: grass-addons/grass6/raster/r.in.ign/r.in.ign
===================================================================
--- grass-addons/grass6/raster/r.in.ign/r.in.ign	2014-03-23 14:18:00 UTC (rev 59295)
+++ grass-addons/grass6/raster/r.in.ign/r.in.ign	2014-03-23 17:08:17 UTC (rev 59296)
@@ -6,12 +6,13 @@
 # AUTHOR(S):		Vincent Bain
 # PURPOSE:		Retrieve wmts channel from IGN, see http://api.ign.fr
 #			Developed for internal use
-# COPYRIGHT:		(C) 2013 by the GRASS Development Team and Toraval-Vincent Bain
+# COPYRIGHT:		(C) 2014 by the GRASS Development Team and Toraval-Vincent Bain
 #			This program is free software under the GNU General
 #			Public License (>=v2). Read the file COPYING that comes
 #			with GRASS for details.
 #
-# VERSION:		2.2
+# VERSION:		2.3
+#			both png and jpeg tiles formats are now supported
 #			Currently only works on PM (EPSG:3857) raster stacks
 #			
 ################################################################################
@@ -62,6 +63,14 @@
 #%end
 
 #%option
+#% key:tiletype
+#% type: string
+#% description: tile format, choose between jpg and png
+#% answer: jpg
+#% required : no
+#%end
+
+#%option
 #% key: output
 #% type: string
 #% gisprompt: new,cell,raster
@@ -177,7 +186,7 @@
 # Testing C flag 
 if [ "$GIS_FLAG_C" -eq 1 ] ; then
 	# fetch capabilities xml file on the server
-		wget -q "http://${USER}:${PASSWORD}@gpp3-wxs.ign.fr/${GIS_OPT_APIKEY}/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities" -O capabilities.xml -O "$GIS_MAP_PATH"/.tmp/ign/capabilities.xml
+		wget -q "http://${USER}:${PASSWORD}@wxs.ign.fr/${GIS_OPT_APIKEY}/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetCapabilities" -O capabilities.xml -O "$GIS_MAP_PATH"/.tmp/ign/capabilities.xml
 	# clean file : IGN xml capabilities happened to be delivered as a one line file
 		xmlstarlet fo "$GIS_MAP_PATH"/.tmp/ign/capabilities.xml > "$GIS_MAP_PATH"/.tmp/ign/fcapab.xml
 	# extract available layers
@@ -266,7 +275,7 @@
 	for j in `seq 0 "$itery"`; do
 		rowk=$(( rowi + j ))
 		# let's feed the URL list file
-		echo "\"https://${GIS_OPT_USER}:${GIS_OPT_PASSWORD}@gpp3-wxs.ign.fr/${GIS_OPT_APIKEY}/geoportail/wmts?LAYER=${GIS_OPT_WMTSLAYER}&EXCEPTIONS=text/xml&FORMAT=image/jpeg&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX=${tilematrix}&TILEROW=${rowk}&TILECOL=${colk}&\"" "-O "$GIS_MAP_PATH"/.tmp/ign/tile"c$i""l$j".jpg" >>"$GIS_MAP_PATH"/.tmp/ign/url.list
+		echo "\"https://${GIS_OPT_USER}:${GIS_OPT_PASSWORD}@wxs.ign.fr/${GIS_OPT_APIKEY}/geoportail/wmts?LAYER=${GIS_OPT_WMTSLAYER}&EXCEPTIONS=text/xml&FORMAT=image/${GIS_OPT_TILETYPE}&SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&STYLE=normal&TILEMATRIXSET=PM&TILEMATRIX=${tilematrix}&TILEROW=${rowk}&TILECOL=${colk}&\"" "-O "$GIS_MAP_PATH"/.tmp/ign/tile"c$i""l$j".${GIS_OPT_TILETYPE}" >>"$GIS_MAP_PATH"/.tmp/ign/url.list
 		((j++))
 	done
 	((i++))
@@ -286,7 +295,7 @@
 		;;
 	esac
 
-xargs -a "$GIS_MAP_PATH"/.tmp/ign/url.list -n 3 -P 64 wget -q
+xargs -a "$GIS_MAP_PATH"/.tmp/ign/url.list -n 3 -P 64 wget -q 
 errwget=$?
 if [ $errwget -eq 6 ]; then
 	g.message -w "Username/password authentication failure... bailing out !"
@@ -304,13 +313,13 @@
 	fi
 	for i in `seq 0 "$iterx"`; do
 		for j in `seq 0 $itery`; do
-			if [ -f "$GIS_MAP_PATH"/.tmp/ign/tile"c$i""l$j".jpg ] ; then
-				size=`stat -c %s "$GIS_MAP_PATH"/.tmp/ign/tile"c$i""l$j".jpg`
+			if [ -f "$GIS_MAP_PATH"/.tmp/ign/tile"c$i""l$j"."${GIS_OPT_TILETYPE}" ] ; then
+				size=`stat -c %s "$GIS_MAP_PATH"/.tmp/ign/tile"c$i""l$j".${GIS_OPT_TILETYPE}`
 			else
 				size=0
 			fi
-			if [ ! -f "$GIS_MAP_PATH"/.tmp/ign/tile"c$i""l$j".jpg -o "$size" -eq 0 ] ; then
-				cat "$GIS_MAP_PATH"/.tmp/ign/url.list | grep tile"c$i""l$j".jpg>>"$GIS_MAP_PATH"/.tmp/ign/urlcorr.list
+			if [ ! -f "$GIS_MAP_PATH"/.tmp/ign/tile"c$i""l$j"."${GIS_OPT_TILETYPE}" -o "$size" -eq 0 ] ; then
+				cat "$GIS_MAP_PATH"/.tmp/ign/url.list | grep tile"c$i""l$j"."${GIS_OPT_TILETYPE}">>"$GIS_MAP_PATH"/.tmp/ign/urlcorr.list
 			fi
 			((j++))
 		done
@@ -349,7 +358,7 @@
 		yk2=`echo "scale=12;$yk1 - $pas * $resol" | bc`
 		
 		# let's feed referencing files (xargs inputs)
-		echo "-gcp 0 0 "$xk1" "$yk1" -gcp 256 256 "$xk2" "$yk2" -gcp 256 0 "$xk2" "$yk1" "$GIS_MAP_PATH"/.tmp/ign/tile"c$i""l$j".jpg "$GIS_MAP_PATH"/.tmp/ign/tile"c$i""l$j".tif" >>"$GIS_MAP_PATH"/.tmp/ign/gdtr1.list
+		echo "-gcp 0 0 "$xk1" "$yk1" -gcp 256 256 "$xk2" "$yk2" -gcp 256 0 "$xk2" "$yk1" "$GIS_MAP_PATH"/.tmp/ign/tile"c$i""l$j".${GIS_OPT_TILETYPE} "$GIS_MAP_PATH"/.tmp/ign/tile"c$i""l$j".tif" >>"$GIS_MAP_PATH"/.tmp/ign/gdtr1.list
 		
 		echo "-of GTiff -a_srs "+init=epsg:3857" "$GIS_MAP_PATH"/.tmp/ign/tile"c$i""l$j".tif "$GIS_MAP_PATH"/.tmp/ign/tiler"c$i""l$j".tif" >>"$GIS_MAP_PATH"/.tmp/ign/gdtr2.list
 		((j++))
@@ -396,18 +405,33 @@
 #---------------------------------------------	
 
 #---------------------------------------------	
-# optionnally make a composite rgb raster
-if [ "$GIS_FLAG_M" -eq 0 ] ; then
-	g.message "compositing raster maps"
-	r.composite output="$GIS_OPT_OUTPUT" red="$GIS_OPT_OUTPUT".red green="$GIS_OPT_OUTPUT".green blue="$GIS_OPT_OUTPUT".blue
-	g.mremove -f rast="$GIS_OPT_OUTPUT".red,"$GIS_OPT_OUTPUT".green,"$GIS_OPT_OUTPUT".blue,"$GIS_OPT_OUTPUT".alpha
-	# write support data
-	r.support map="$GIS_OPT_OUTPUT" title="${GIS_OPT_WMTSLAYER} extracted from ign wmts service" history="${CMDLINE}"
+# check if we have a multi-band or a single-band raster
+eval `g.findfile element=cell file=$GIS_OPT_OUTPUT.1`
+echo "voyons $file"
+
+if [ "$file" ] ; then
+	g.remove rast=$GIS_OPT_OUTPUT.alpha
+	g.rename rast=$GIS_OPT_OUTPUT.1,$GIS_OPT_OUTPUT
+	i.group -r group=$GIS_OPT_OUTPUT input=$GIS_OPT_OUTPUT.alpha,$GIS_OPT_OUTPUT.1
+	i.group group=$GIS_OPT_OUTPUT input=$GIS_OPT_OUTPUT
+	r.support map=$GIS_OPT_OUTPUT title="${GIS_OPT_WMTSLAYER} extracted from ign wmts service" history="${CMDLINE}"
 else
-	# write support data for each band
-	for i in {red,green,blue} ; do
-		r.support map="$GIS_OPT_OUTPUT".$i title="${GIS_OPT_WMTSLAYER} extracted from ign wmts service" history="${CMDLINE}"
-	done
+	# optionnally make a composite rgb raster
+	if [ "$GIS_FLAG_M" -eq 0 ] ; then
+		g.message "compositing raster maps"
+		r.composite output="$GIS_OPT_OUTPUT" red="$GIS_OPT_OUTPUT".red green="$GIS_OPT_OUTPUT".green blue="$GIS_OPT_OUTPUT".blue
+		g.mremove -f rast="$GIS_OPT_OUTPUT".red,"$GIS_OPT_OUTPUT".green,"$GIS_OPT_OUTPUT".blue,"$GIS_OPT_OUTPUT".alpha
+		i.group -r group=$GIS_OPT_OUTPUT input=$GIS_OPT_OUTPUT.alpha,$GIS_OPT_OUTPUT.red,$GIS_OPT_OUTPUT.green,$GIS_OPT_OUTPUT.blue
+		i.group group=$GIS_OPT_OUTPUT input=$GIS_OPT_OUTPUT
+		# write support data
+		r.support map="$GIS_OPT_OUTPUT" title="${GIS_OPT_WMTSLAYER} extracted from ign wmts service" history="${CMDLINE}"
+	else
+		# write support data for each band
+		for i in {red,green,blue} ; do
+			r.support map="$GIS_OPT_OUTPUT".$i title="${GIS_OPT_WMTSLAYER} extracted from ign wmts service" history="${CMDLINE}"
+		done
+		g.remove rast=$GIS_OPT_OUTPUT.alpha
+	fi
 fi
 
 



More information about the grass-commit mailing list