[GRASS-SVN] r66055 - grass-addons/grass7/vector/v.in.gbif

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 28 09:13:57 PDT 2015


Author: hellik
Date: 2015-08-28 09:13:57 -0700 (Fri, 28 Aug 2015)
New Revision: 66055

Modified:
   grass-addons/grass7/vector/v.in.gbif/v.in.gbif.html
   grass-addons/grass7/vector/v.in.gbif/v.in.gbif.py
Log:
v.in.gbif: on-the-fly reprojecting implemeted by using v.import (TODO: re-projection error handling, v.import test)

Modified: grass-addons/grass7/vector/v.in.gbif/v.in.gbif.html
===================================================================
--- grass-addons/grass7/vector/v.in.gbif/v.in.gbif.html	2015-08-28 14:31:54 UTC (rev 66054)
+++ grass-addons/grass7/vector/v.in.gbif/v.in.gbif.html	2015-08-28 16:13:57 UTC (rev 66055)
@@ -1,7 +1,7 @@
 <h2>DESCRIPTION</h2>
 
 <em>v.in.gbif</em> imports <a href="http://www.gbif.org/">GBIF</a> 
-species distribution data. The location must be in latlon (WGS84). 
+species distribution data. GBIF data is by definition in WGS84 geographic coordinates.
 
 <p>
 The species distribution data downloaded from <a href="http://www.gbif.org/">GBIF</a> 
@@ -19,6 +19,14 @@
 the columns will renamed with the prefix <i>g_</i>. 
 </p>
 
+<p>
+ By the <i>-r</i> flag an on-the-fly reprojection of the data can be 
+invoked using <a href="v.import.html">v.import</a>, if the location is 
+not in WGS84. Quality of on-the-fly reprojection is not garanteed. The 
+traditional reprojection procedure in GRASS GIS can also be used 
+instead.
+</p>
+
 <h2>EXAMPLE</h2>
 
 <div class="code">
@@ -33,8 +41,10 @@
 <h2>SEE ALSO</h2>
 
 <em>
+<a href="v.import.html">v.import</a>
 <a href="v.in.ascii.html">v.in.ascii</a>
 <a href="v.in.ogr.html">v.in.ogr</a>
+<a href="v.proj.html">v.proj</a>
 </em>
 
 <h2>AUTHOR</h2>

Modified: grass-addons/grass7/vector/v.in.gbif/v.in.gbif.py
===================================================================
--- grass-addons/grass7/vector/v.in.gbif/v.in.gbif.py	2015-08-28 14:31:54 UTC (rev 66054)
+++ grass-addons/grass7/vector/v.in.gbif/v.in.gbif.py	2015-08-28 16:13:57 UTC (rev 66055)
@@ -45,6 +45,10 @@
 #% guisection: vrt
 #%end
 
+#%flag
+#% key: r
+#% description: Reproject data on-the-fly if no latlon (WGS84) location
+#%end
 
 import sys
 import os
@@ -60,15 +64,7 @@
 
 def main():
 
-    # check for unsupported locations
-    in_proj = grass.parse_command('g.proj', flags='g')
-    if in_proj['unit'].lower() == 'meter':
-        grass.fatal(_("Projected locations are not supported"))
-    if in_proj['unit'].lower() == 'us survey foot':
-        grass.fatal(_("Projected locations are not supported"))
-    if in_proj['name'].lower() == 'xy_location_unprojected':
-        grass.fatal(_("xy-locations are not supported"))
-
+		
     gbifraw = options['input']
     gbifimported = options['output']
     directory = options['dir']
@@ -76,8 +72,15 @@
     gbifvrt = gbifimported+'.vrt'
     gbif_vrt_layer = gbifimported
     gbifcsv = gbifimported+'.csv'	
+    reproject_gbif = flags['r']
     global tmp	 
-	
+
+    # check for unsupported locations or unsupported combination of option and projected location
+    in_proj = grass.parse_command('g.proj', flags='g')
+    
+    if in_proj['name'].lower() == 'xy_location_unprojected':
+        grass.fatal(_("xy-locations are not supported"))
+		
     # Extract vector line
     grass.message( "Starting importing GBIF data ..." )
     grass.message( "preparing data for vrt ..." )
@@ -163,13 +166,25 @@
 
     # import GBIF vrt
     grass.message( "importing GBIF vrt ..." )
+    
+    # reprojection-on-the-fly if flag r
+    	
+    if reproject_gbif :
+		
+		grass.message( "reprojecting data on-the-fly ..." )
+		grass.run_command("v.import", input = new_gbif_vrt,
+                                     output = gbifimported,
+                                     quiet = True)
 
-    grass.run_command("v.in.ogr", input = new_gbif_vrt,
+	# no reprojection-on-the-fly
+	
+    else:
+		
+		grass.run_command("v.in.ogr", input = new_gbif_vrt,
                                      layer = gbif_vrt_layer,
                                      output = gbifimported,
                                      quiet = True)
 
-
     grass.message( "..." )
     # v.in.gbif done!	
     grass.message( "importing GBIF data done!" )



More information about the grass-commit mailing list