<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=%E2%9A%A0%EF%B8%8FHarrikoo</id>
	<title>GRASS-Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://grasswiki.osgeo.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=%E2%9A%A0%EF%B8%8FHarrikoo"/>
	<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/wiki/Special:Contributions/%E2%9A%A0%EF%B8%8FHarrikoo"/>
	<updated>2026-05-27T17:39:26Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=R_statistics&amp;diff=6923</id>
		<title>R statistics</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=R_statistics&amp;diff=6923"/>
		<updated>2008-06-30T09:10:53Z</updated>

		<summary type="html">&lt;p&gt;⚠️Harrikoo: /* See also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Q:''' How do I enjoy high quality statistic analysis in GRASS?&lt;br /&gt;
&lt;br /&gt;
'''A:''' Well, GRASS has got an interface to the most powerful statistics analysis package around: '''''R''''' (http://www.r-project.org)&lt;br /&gt;
&lt;br /&gt;
First of all you need to add '''''R''''' to your system, the '''''R''''' version must be &amp;gt;= 1.9.1:&lt;br /&gt;
&lt;br /&gt;
* '''Debian GNU/Linux''' user, see: http://cran.r-project.org/bin/linux/debian/README&lt;br /&gt;
* '''Ubuntu Linux''' see: http://cran.r-project.org/bin/linux/ubuntu/README&lt;br /&gt;
* '''RedHat, Suse, Mandrake''' and similar distros: take the latest '''''R''''' RPM and install it&lt;br /&gt;
&lt;br /&gt;
Once you have '''''R''''' in your system, take a look at http://grass.itc.it/statsgrass/grass_r_install.html.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Quick start ===&lt;br /&gt;
For the impatient just start it:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt; R&lt;br /&gt;
  &lt;br /&gt;
  #and install packages directly from the net&lt;br /&gt;
  pkgs &amp;lt;- c('akima', 'spgrass6', 'RODBC', 'VR')&lt;br /&gt;
  &lt;br /&gt;
  install.packages(pkgs, dependencies=TRUE, type='source') &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
&lt;br /&gt;
* All the necessary functions for the GRASS 6 interface are now in packages on CRAN, so that on Linux/Unix (or Mac OSX) installing rgdal from source with PROJ4 and GDAL installed, or Windows installing from binary, the required packages are: sp; maptools (now includes spmaptools); rgdal (now includes spGDAL, spproj); spgrass6 - now all on CRAN.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== See also ===&lt;br /&gt;
&lt;br /&gt;
* http://grass.ibiblio.org/statsgrass/index.php#grassR&lt;br /&gt;
&lt;br /&gt;
* Using GRASS and R: http://grass.itc.it/statsgrass/grass_r_interface.html&lt;br /&gt;
&lt;br /&gt;
* Connecting R to RDBMS: http://grass.itc.it/statsgrass/r_and_dbms.html&lt;br /&gt;
&lt;br /&gt;
* R-Statistics homepage  http://www.r-project.org&lt;br /&gt;
&lt;br /&gt;
* R Spatial Projects http://sal.uiuc.edu/csiss/Rgeo//&lt;br /&gt;
&lt;br /&gt;
* http://r-spatial.sourceforge.net/xtra/xtra.RHnw.html#spgrass6&lt;br /&gt;
&lt;br /&gt;
* Neural Networks with GRASS and R (posted by Markus Neteler on the grass-user mailing list) http://www.uam.es/proyectosinv/Mclim/pdf/MBenito_EcoMod.pdf&lt;br /&gt;
&lt;br /&gt;
* A detailed example on the use of GRASS and R, with spearfish data: http://casoilresource.lawr.ucdavis.edu/drupal/node/438&lt;br /&gt;
&lt;br /&gt;
* Using R and GRASS with cygwin: It is possible to use Rterm inside the GRASS shell in cygwin, just as in Unix/Linux or OSX. You should not, however, start Rterm from a cygwin xterm, because Rterm is not expecting to be run in an xterm under Windows, and loses its input. If you use the regular cygwin bash shell, but need to start display windows, start X from within GRASS with startx &amp;amp;, and then start Rterm in the same cygwin shell, not in the xterm.&lt;br /&gt;
&lt;br /&gt;
* [http://r-spatial.sourceforge.net/ Spatial data in R] (&amp;lt;code&amp;gt;sp&amp;lt;/code&amp;gt;) is a '''''R''''' library that provides classes and methods for spatial data (points, lines, polygons, grids), and to new or existing spatial statistics '''''R''''' packages that use sp, depend on sp, or will become dependent on &amp;lt;code&amp;gt;sp&amp;lt;/code&amp;gt;, such as &amp;lt;code&amp;gt;maptools&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rgdal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;splancs&amp;lt;/code&amp;gt;, '''&amp;lt;code&amp;gt;spgrass6&amp;lt;/code&amp;gt;''', &amp;lt;code&amp;gt;gstat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;spgwr&amp;lt;/code&amp;gt; and many others.&lt;br /&gt;
&lt;br /&gt;
* [http://rpy.sourceforge.net/ RPy] - Python interface to the R Programming Language&lt;br /&gt;
&lt;br /&gt;
=== Articles ===&lt;br /&gt;
&lt;br /&gt;
* [http://grass.itc.it/newsletter/grassnews3.html GRASS News vol.3], June 2005 (R. Bivand. Interfacing GRASS 6 and R. ''GRASS Newsletter'', 3:11-16, June 2005. ISSN 1614-8746).&lt;br /&gt;
* OSGeo Journal vol. 1 May 2007 (R. Bivand. Using the R— GRASS interface. ''OSGeo Journal'', 1:31-33, May 2007. ISSN 1614-8746).&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:FAQ]]&lt;/div&gt;</summary>
		<author><name>⚠️Harrikoo</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=R_statistics&amp;diff=6922</id>
		<title>R statistics</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=R_statistics&amp;diff=6922"/>
		<updated>2008-06-30T09:10:14Z</updated>

		<summary type="html">&lt;p&gt;⚠️Harrikoo: A link to a very good example&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Q:''' How do I enjoy high quality statistic analysis in GRASS?&lt;br /&gt;
&lt;br /&gt;
'''A:''' Well, GRASS has got an interface to the most powerful statistics analysis package around: '''''R''''' (http://www.r-project.org)&lt;br /&gt;
&lt;br /&gt;
First of all you need to add '''''R''''' to your system, the '''''R''''' version must be &amp;gt;= 1.9.1:&lt;br /&gt;
&lt;br /&gt;
* '''Debian GNU/Linux''' user, see: http://cran.r-project.org/bin/linux/debian/README&lt;br /&gt;
* '''Ubuntu Linux''' see: http://cran.r-project.org/bin/linux/ubuntu/README&lt;br /&gt;
* '''RedHat, Suse, Mandrake''' and similar distros: take the latest '''''R''''' RPM and install it&lt;br /&gt;
&lt;br /&gt;
Once you have '''''R''''' in your system, take a look at http://grass.itc.it/statsgrass/grass_r_install.html.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Quick start ===&lt;br /&gt;
For the impatient just start it:&lt;br /&gt;
&lt;br /&gt;
  &amp;gt; R&lt;br /&gt;
  &lt;br /&gt;
  #and install packages directly from the net&lt;br /&gt;
  pkgs &amp;lt;- c('akima', 'spgrass6', 'RODBC', 'VR')&lt;br /&gt;
  &lt;br /&gt;
  install.packages(pkgs, dependencies=TRUE, type='source') &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Notes ===&lt;br /&gt;
&lt;br /&gt;
* All the necessary functions for the GRASS 6 interface are now in packages on CRAN, so that on Linux/Unix (or Mac OSX) installing rgdal from source with PROJ4 and GDAL installed, or Windows installing from binary, the required packages are: sp; maptools (now includes spmaptools); rgdal (now includes spGDAL, spproj); spgrass6 - now all on CRAN.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== See also ===&lt;br /&gt;
&lt;br /&gt;
* http://grass.ibiblio.org/statsgrass/index.php#grassR&lt;br /&gt;
&lt;br /&gt;
* Using GRASS and R: http://grass.itc.it/statsgrass/grass_r_interface.html&lt;br /&gt;
&lt;br /&gt;
* Connecting R to RDBMS: http://grass.itc.it/statsgrass/r_and_dbms.html&lt;br /&gt;
&lt;br /&gt;
* R-Statistics homepage  http://www.r-project.org&lt;br /&gt;
&lt;br /&gt;
* R Spatial Projects http://sal.uiuc.edu/csiss/Rgeo//&lt;br /&gt;
&lt;br /&gt;
* http://r-spatial.sourceforge.net/xtra/xtra.RHnw.html#spgrass6&lt;br /&gt;
&lt;br /&gt;
* Neural Networks with GRASS and R (posted by Markus Neteler on the grass-user mailing list) http://www.uam.es/proyectosinv/Mclim/pdf/MBenito_EcoMod.pdf&lt;br /&gt;
&lt;br /&gt;
* A detailed example on the use of GRASS data from R, with spearfish data: http://casoilresource.lawr.ucdavis.edu/drupal/node/438&lt;br /&gt;
&lt;br /&gt;
* Using R and GRASS with cygwin: It is possible to use Rterm inside the GRASS shell in cygwin, just as in Unix/Linux or OSX. You should not, however, start Rterm from a cygwin xterm, because Rterm is not expecting to be run in an xterm under Windows, and loses its input. If you use the regular cygwin bash shell, but need to start display windows, start X from within GRASS with startx &amp;amp;, and then start Rterm in the same cygwin shell, not in the xterm.&lt;br /&gt;
&lt;br /&gt;
* [http://r-spatial.sourceforge.net/ Spatial data in R] (&amp;lt;code&amp;gt;sp&amp;lt;/code&amp;gt;) is a '''''R''''' library that provides classes and methods for spatial data (points, lines, polygons, grids), and to new or existing spatial statistics '''''R''''' packages that use sp, depend on sp, or will become dependent on &amp;lt;code&amp;gt;sp&amp;lt;/code&amp;gt;, such as &amp;lt;code&amp;gt;maptools&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;rgdal&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;splancs&amp;lt;/code&amp;gt;, '''&amp;lt;code&amp;gt;spgrass6&amp;lt;/code&amp;gt;''', &amp;lt;code&amp;gt;gstat&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;spgwr&amp;lt;/code&amp;gt; and many others.&lt;br /&gt;
&lt;br /&gt;
* [http://rpy.sourceforge.net/ RPy] - Python interface to the R Programming Language&lt;br /&gt;
&lt;br /&gt;
=== Articles ===&lt;br /&gt;
&lt;br /&gt;
* [http://grass.itc.it/newsletter/grassnews3.html GRASS News vol.3], June 2005 (R. Bivand. Interfacing GRASS 6 and R. ''GRASS Newsletter'', 3:11-16, June 2005. ISSN 1614-8746).&lt;br /&gt;
* OSGeo Journal vol. 1 May 2007 (R. Bivand. Using the R— GRASS interface. ''OSGeo Journal'', 1:31-33, May 2007. ISSN 1614-8746).&lt;br /&gt;
&lt;br /&gt;
[[Category:Installation]]&lt;br /&gt;
[[Category:FAQ]]&lt;/div&gt;</summary>
		<author><name>⚠️Harrikoo</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=How_to_interpolate_point_value_using_kriging_method_with_R_and_GRASS_6&amp;diff=5589</id>
		<title>How to interpolate point value using kriging method with R and GRASS 6</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=How_to_interpolate_point_value_using_kriging_method_with_R_and_GRASS_6&amp;diff=5589"/>
		<updated>2007-12-14T09:10:54Z</updated>

		<summary type="html">&lt;p&gt;⚠️Harrikoo: /* ORDINARY KRIGING IN R WITH GRASS6 DATA */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=== ORDINARY KRIGING IN R WITH GRASS6 DATA ===&lt;br /&gt;
&lt;br /&gt;
('''WARNING!!''' Most of the code quoted here is very out of date, and simply does not work for current R/sp/gstat/spgrass6. Untried suggestions have been edited in, but without a test location, there is no guarantee that they will work! Roger Bivand, 5 April 2007)&lt;br /&gt;
&lt;br /&gt;
Of all the methods we tried this is the most easy and (I suppose) exact too:&lt;br /&gt;
&lt;br /&gt;
You have to have in your library the packages &amp;quot;gstat&amp;quot; and &amp;quot;spgrass6&amp;quot;, you can download this last one directly from R using the command &amp;quot;install.packages&amp;quot;.&lt;br /&gt;
In GRASS we have a vector file named &amp;quot;giaciture_cat_clean3&amp;quot; and we want to do a prediction on this data...&lt;br /&gt;
these are the commmands:&lt;br /&gt;
&lt;br /&gt;
enter R from the GRASS prompt, and type:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
library(spgrass6) &lt;br /&gt;
&lt;br /&gt;
#get vector points as SpatialPointsDataFrame &lt;br /&gt;
#giaciture &amp;lt;- getSites6sp(&amp;quot;giaciture_cat_clean3&amp;quot;) RSB 070405&lt;br /&gt;
&lt;br /&gt;
giaciture &amp;lt;- readVECT6(&amp;quot;giaciture_cat_clean3&amp;quot;) # RSB 070405&lt;br /&gt;
&lt;br /&gt;
class(giaciture) #shows the class of &amp;quot;giaciture&amp;quot; (SpatialPointsDataFrame)&lt;br /&gt;
 &lt;br /&gt;
# G &amp;lt;- gmeta6() #get region from GRASS to R  RSB 070405&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
now if you want you can continue to work in R from GRASS or not...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#create a grid from the region settings of GRASS, it is very important&lt;br /&gt;
# to have square cells, so you can set the region settings of GRASS or&lt;br /&gt;
# you can give directly square dimensions using the values:  &lt;br /&gt;
# e.g.&amp;quot;cells.dim=c(50,50)&amp;quot;&lt;br /&gt;
#grd &amp;lt;- GridTopology(cellcentre.offset=c(G$west+(G$ewres/2)&lt;br /&gt;
#                    ,G$south+(G$nsres/2))&lt;br /&gt;
#                    ,cellsize=c(G$ewres, G$nsres)&lt;br /&gt;
#                    ,cells.dim=c(G$cols, G$rows)) RSB 070405&lt;br /&gt;
&lt;br /&gt;
grd &amp;lt;- gmeta2grd() # RSB 070405&lt;br /&gt;
&lt;br /&gt;
#create a SpatialGridDataFrame&lt;br /&gt;
mask_SG &amp;lt;- SpatialGridDataFrame(grd,&lt;br /&gt;
#                                ,data=list(k=rep(1, G$cols*G$rows)) RSB 070405&lt;br /&gt;
     data=data.frame(k=rep(1, prod(slot(grd, &amp;quot;cells.dim&amp;quot;)))), # RSB 070405&lt;br /&gt;
     proj4string=CRS(proj4string(giaciture))) # RSB 070405&lt;br /&gt;
# proj4string(giaciture) and proj4string(mask_SG) must agree&lt;br /&gt;
class(mask_SG)&lt;br /&gt;
&lt;br /&gt;
library(gstat)&lt;br /&gt;
&lt;br /&gt;
cvgm &amp;lt;- variogram(IMMERSIONE~1, data=giaciture, width=400, cutoff=4000) # RSB 070405&lt;br /&gt;
#create variogram, and &amp;quot;IMMERSIONE&amp;quot; &lt;br /&gt;
#here is the our variable, the variable on wich we have to do the prediction,&lt;br /&gt;
# ~ 1 select the type of kriging, this is the ordinary one&lt;br /&gt;
&lt;br /&gt;
efitted &amp;lt;- fit.variogram(cvgm, vgm(psill=5000, model=&amp;quot;Exp&amp;quot;, range=1500, nugget=8000))&lt;br /&gt;
# choose the model to fit variogram (here is exponential) and give the&lt;br /&gt;
# estimated parameters of the variogram (partial sill, range and nugget)&lt;br /&gt;
&lt;br /&gt;
OK_pred &amp;lt;- krige(IMMERSIONE~1, data=giaciture, newdata=mask_SG, model=efitted) # RSB 070405&lt;br /&gt;
# make the kriging prediction&lt;br /&gt;
&lt;br /&gt;
names(OK_pred) #show the name of variable kriged&lt;br /&gt;
&lt;br /&gt;
writeRAST6(OK_pred, &amp;quot;OK_pred&amp;quot;, zcol=&amp;quot;var1.pred&amp;quot;) # RSB 070405&lt;br /&gt;
#write a raster file and save it in GRASS, now you can open it from there.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
that's all! &lt;br /&gt;
&lt;br /&gt;
special thanks to Roger Bivand, ever ready to lend a hand!&lt;br /&gt;
&lt;br /&gt;
=== More Help ===&lt;br /&gt;
&lt;br /&gt;
A [http://casoilresource.lawr.ucdavis.edu/drupal/node/438 nice working example] for recent versions of R/sp/gstat/spgrass6.&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Harrikoo</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_Help&amp;diff=2959</id>
		<title>GRASS Help</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_Help&amp;diff=2959"/>
		<updated>2006-11-05T00:06:19Z</updated>

		<summary type="html">&lt;p&gt;⚠️Harrikoo: /* Interfacing with external software */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Getting Started ==&lt;br /&gt;
&lt;br /&gt;
=== Installation ===&lt;br /&gt;
&lt;br /&gt;
* Covered in the [[Installation Guide]]&lt;br /&gt;
&lt;br /&gt;
=== Frequently Asked Questions ===&lt;br /&gt;
&lt;br /&gt;
* [[Faq|FAQ]]&lt;br /&gt;
* You can contact GRASS users in [[How to participate in IRC communication|IRC]]&lt;br /&gt;
&lt;br /&gt;
=== First Day Documentation ===&lt;br /&gt;
* [http://grass.itc.it/grass61/manuals/html61_user/helptext.html GRASS Quickstart] by M. Neteler (in the GRASS help pages)&lt;br /&gt;
&lt;br /&gt;
* [http://wwwamb.bologna.enea.it/forgrass/documents/Grass-6-Visual-Tutorial.pdf Visual Tutorial for GRASS 6] by L. Moretti (for non-UNIX people, GUI)&lt;br /&gt;
&lt;br /&gt;
* [[Gis Concepts|Basic GIS concepts]] and how GRASS implements them&lt;br /&gt;
&lt;br /&gt;
* [http://mpa.itc.it/markus/osg05/ GRASS 6 in a nutshell] by M. Neteler (short tutorial, also translated to Spanish and French)&lt;br /&gt;
&lt;br /&gt;
* [http://www.gdf-hannover.de/lit_html/grass60_v1.2_en/index.html An introduction to the practical use of the Free Geographical Information System GRASS 6.0] by GDF Hannover&lt;br /&gt;
&lt;br /&gt;
* [http://www.gdf-hannover.de/media.php?id=0&amp;amp;lg=en More tutorials] from GDF Hannover&lt;br /&gt;
&lt;br /&gt;
* [http://mpa.itc.it/grasstutor/index.phtml Open Source GIS: A GRASS GIS Approach. 2nd ed.] by M. Neteler and H. Mitasova &amp;lt;BR&amp;gt; (Book; focus is on GRASS 5, but all chapters still valid except vector/sites for that read the [http://mpa.itc.it/grasstutor/grass6/ updates page])&lt;br /&gt;
&lt;br /&gt;
* GRASS module [http://grass.ibiblio.org/grass61/manuals/html61_user/index.html  reference manuals]&lt;br /&gt;
&lt;br /&gt;
* More GRASS [http://grass.ibiblio.org/gdp/index.php documentation and tutorials]&lt;br /&gt;
&lt;br /&gt;
=== Sample Dataset ===&lt;br /&gt;
&lt;br /&gt;
* [http://grass.ibiblio.org/download/data6.php Spearfish County, SD, USA] (not so far from Mount Rushmore) with [http://mpa.itc.it/markus/osg05/ extra data]&lt;br /&gt;
* [http://grass.ibiblio.org/download/data.php More sample data]&lt;br /&gt;
&lt;br /&gt;
=== Migration from other GIS Software ===&lt;br /&gt;
&lt;br /&gt;
* [[GRASS_migration_hints|GRASS migration hints]]&lt;br /&gt;
* [[GIS to GRASS command translation|GIS Software to GRASS command translation table and discussion]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Interfacing with external software ==&lt;br /&gt;
&lt;br /&gt;
* [[Tips_and_Tricks#Using_QGIS_as_a_frontend_to_GRASS| QGIS]] frontend&lt;br /&gt;
* [[Tips_and_Tricks#Interfacing_R-Statistics_with_GRASS| R statistics]] interface&lt;br /&gt;
* [[Tips_and_Tricks#Exporting_GRASS_maps_to_GMT| GMT mapping]] cartography&lt;br /&gt;
* [[GRASS_and_MapServer| MapServer]] web server&lt;br /&gt;
* External databases ([http://grass.itc.it/grass62/manuals/html62_user/db.connect.html db.connect])&lt;br /&gt;
* External vector data ([http://grass.itc.it/grass62/manuals/html62_user/v.external.html v.external])&lt;br /&gt;
* Paraview 3D visualization (r.out.vtk,  [http://grass.itc.it/grass62/manuals/html62_user/r3.out.vtk.html r3.out.vtk], v.out.vtk)&lt;br /&gt;
* POVray 3D visualization ([http://grass.itc.it/grass62/manuals/html62_user/r.out.pov.html r.out.pov], v.out.pov)&lt;br /&gt;
&lt;br /&gt;
== Further Reading ==&lt;br /&gt;
&lt;br /&gt;
* [[Documents|Full GRASS Documentation]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Misc. Help ==&lt;br /&gt;
&lt;br /&gt;
* [[GRASS FAQ]] (see also: [[GRASS 6 Tutorial]])&lt;br /&gt;
* [[Tips and Tricks]]&lt;br /&gt;
* [[Compile and install GRASS and QGIS with GDAL/OGR Plugin]]&lt;br /&gt;
* [[How to interpolate point value using kriging method with R and GRASS 6]]&lt;br /&gt;
* [[GRASS vector export to Inkscape]]&lt;br /&gt;
&lt;br /&gt;
--------&lt;br /&gt;
* Wiki [[Help]] (how to edit pages after registration)&lt;/div&gt;</summary>
		<author><name>⚠️Harrikoo</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_MapServer&amp;diff=2958</id>
		<title>GRASS and MapServer</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_MapServer&amp;diff=2958"/>
		<updated>2006-11-05T00:04:16Z</updated>

		<summary type="html">&lt;p&gt;⚠️Harrikoo: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==GRASS maps from mapfiles==&lt;br /&gt;
&lt;br /&gt;
MapServer needs a mapfile containing the information, how to create the maps. Examples of these can be found, so here you'll find GRASS specific information.&lt;br /&gt;
&lt;br /&gt;
==Raster Maps==&lt;br /&gt;
&lt;br /&gt;
A shor example of a layer definition to access a GRASS raster:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
LAYER&lt;br /&gt;
  NAME &amp;quot;Example&amp;quot;&lt;br /&gt;
  TYPE RASTER&lt;br /&gt;
  STATUS ON&lt;br /&gt;
  DATA &amp;quot;/path/to/grassdb/location/mapset/cellhd/example&amp;quot;&lt;br /&gt;
  CLASS NAME &amp;quot;Example&amp;quot; # You need to have a class definition in the layer&lt;br /&gt;
  END&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* The rasters are limited to values form 0 to 255, the values over this are interpreted as 255. Rescale (&amp;lt;code&amp;gt;r.rescale&amp;lt;/code&amp;gt;) your maps when necessary.&lt;br /&gt;
* You really need to have a CLASS in your layer, otherwise no data will be shown. An empty class is quite fine to show the whole map.&lt;br /&gt;
&lt;br /&gt;
==Vector Maps==&lt;br /&gt;
&lt;br /&gt;
A short example of a layer definition to access a GRASS vector:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
LAYER&lt;br /&gt;
  NAME &amp;quot;Example&amp;quot;&lt;br /&gt;
  TYPE LINE&lt;br /&gt;
  STATUS ON&lt;br /&gt;
  CONNECTIONTYPE OGR&lt;br /&gt;
  CONNECTION &amp;quot;/path/to/grassdb/mapset/location/vector/example/head&amp;quot;&lt;br /&gt;
  DATA &amp;quot;1&amp;quot; # Layer number&lt;br /&gt;
  CLASS # You need to have a class definition; otherwise nothing is shown on the map&lt;br /&gt;
    NAME &amp;quot;Example&amp;quot;&lt;br /&gt;
    COLOR 155 155 0&lt;br /&gt;
  END&lt;br /&gt;
END&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Notes:&lt;br /&gt;
&lt;br /&gt;
* You need to have GDAL with OGR and GRASS support for this to work. Note, that in this [http://grass.itc.it/start.html example] the maps are first exported to shapefiles. This is no longer necessary, as the maps can be accessed directly with OGR.&lt;br /&gt;
* Usually GRASS layers have no names and the layer number is used in DATA. However, it is possible that they do have names. This can happen for example when importing files with v.in.dxf, as the module keeps the dxf-file layer names and stores them into the GRASS vector. The layer names, if such there are, can be found in &amp;lt;tt&amp;gt;/path/to/grassdb/mapset/location/vector/vectorname/dbln&amp;lt;/tt&amp;gt;, or with &amp;lt;code&amp;gt;ogrinfo -ro /path/to/grassdb/mapset/location/vector/vectorname/dbln&amp;lt;/code&amp;gt;. Why this is so important is because if there are layer names defined, these layers cannot be accessed through the layer number with OGR. They ''have'' to be accessed through the layer name.&lt;br /&gt;
&lt;br /&gt;
==Examples and useful links==&lt;br /&gt;
&lt;br /&gt;
* [http://grass.itc.it/start.html Example] of GRASS with MapServer.&lt;br /&gt;
* [http://mapserver.gis.umn.edu UMN Mapserver homepage]&lt;/div&gt;</summary>
		<author><name>⚠️Harrikoo</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=Tips_and_Tricks&amp;diff=2957</id>
		<title>Tips and Tricks</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=Tips_and_Tricks&amp;diff=2957"/>
		<updated>2006-11-04T23:25:40Z</updated>

		<summary type="html">&lt;p&gt;⚠️Harrikoo: /* Using GRASS with an on-line Web-GIS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Tips and Tricks==&lt;br /&gt;
&lt;br /&gt;
===Using QGIS as a frontend to GRASS===&lt;br /&gt;
&lt;br /&gt;
QGIS can run as a frontend to GRASS. There is support for displaying maps, editing maps, and execution of simple GIS functions. The GDAL/OGR library is a requirement for that (but for GRASS anyway):&lt;br /&gt;
&lt;br /&gt;
* QGIS homepage:  http://qgis.org&lt;br /&gt;
* GDAL homepage:  http://www.gdal.org&lt;br /&gt;
&lt;br /&gt;
To use the two together, the GDAL-GRASS plugin must be installed:&lt;br /&gt;
&lt;br /&gt;
* [[Compile and install GRASS and QGIS with GDAL/OGR Plugin]]&lt;br /&gt;
&lt;br /&gt;
Test that the GDAL-GRASS plugin is available with this command:&amp;lt;BR&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  gdalinfo --formats&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Look for a line like &amp;quot;GRASS (ro): GRASS Database Rasters (5.7+)&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Enable the QGIS GRASS plugin from QGIS: &amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  GUI: Plugins / Plugin Manager / Check the GRASS checkbox&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The GRASS toolbar should now be visible.&lt;br /&gt;
While not a firm requirement, it is easier to start QGIS from within a GRASS session.&lt;br /&gt;
&lt;br /&gt;
* [http://wiki.qgis.org/qgiswiki/GrassCookbook QGIS GRASS Cookbook] - Recipes for common tasks&lt;br /&gt;
&lt;br /&gt;
===Exporting GRASS maps to GMT===&lt;br /&gt;
&lt;br /&gt;
GMT (Generic Mapping Tools) is a Free software package for creating publication quality cartography.&lt;br /&gt;
&lt;br /&gt;
GMT homepage:  http://gmt.soest.hawaii.edu&lt;br /&gt;
&lt;br /&gt;
Exporting GRASS maps to GMT:  http://169.237.35.250/~dylan/grass_user_group/#GMT_and_GRASS-overview&lt;br /&gt;
&amp;lt;BR&amp;gt;(Supplied by the GRASS Users Group of Davis, California)&lt;br /&gt;
&lt;br /&gt;
===Interfacing R-Statistics with GRASS===&lt;br /&gt;
&lt;br /&gt;
* http://grass.ibiblio.org/statsgrass/index.php#grassR&lt;br /&gt;
&lt;br /&gt;
* R-Statistics homepage  http://www.r-project.org&lt;br /&gt;
&lt;br /&gt;
* R Spatial Projects http://sal.uiuc.edu/csiss/Rgeo//&lt;br /&gt;
&lt;br /&gt;
* http://r-spatial.sourceforge.net/xtra/xtra.RHnw.html#spgrass6&lt;br /&gt;
&lt;br /&gt;
* Neural Networks with GRASS and R (posted by Markus Neteler on the grass-user mailing list) http://www.uam.es/proyectosinv/Mclim/pdf/MBenito_EcoMod.pdf&lt;br /&gt;
&lt;br /&gt;
===Using GRASS with an on-line Web-GIS===&lt;br /&gt;
&lt;br /&gt;
see:&lt;br /&gt;
&lt;br /&gt;
* [[GRASS and MapServer]]&lt;br /&gt;
* [[GRASS and PHP]]&lt;br /&gt;
* [[GRASS and Python]]&lt;br /&gt;
&lt;br /&gt;
(please expand)&lt;br /&gt;
&lt;br /&gt;
===Starting and running GRASS from a script===&lt;br /&gt;
&lt;br /&gt;
See [[GRASS and Shell]].&lt;br /&gt;
&lt;br /&gt;
===Running GRASS remotely on OS X===&lt;br /&gt;
&lt;br /&gt;
Tiger (OS 10.4) changed the default configuration of SSH from previous versions of OS X. You can no longer start  an ssh session with the -X flag and display the Tcl/Tk components of the GRASS GUI remotely. If you are running grass on OS X (10.4) between hosts on a network (i.e. running it on one machine but displaying it on another), you will need to use the &amp;quot;trusted forwarding&amp;quot; mode of SSH in order for the Tcl/Tk generated graphics, such as d.m or gis.m in order for the GUI graphics to make it through your connection. This can be done using the -Y flag when you start the ssh session:&lt;br /&gt;
&lt;br /&gt;
 ssh -Y remotehost&lt;br /&gt;
&lt;br /&gt;
or add this to ~/.ssh/config:&lt;br /&gt;
&lt;br /&gt;
 Host hostname&lt;br /&gt;
   ForwardX11 yes&lt;br /&gt;
   ForwardX11Trusted yes&lt;br /&gt;
&lt;br /&gt;
Using the -X flag, or simply turning on X11Forwarding in the SSH configuration files, is not enough:  the symptoms in this case are that a d.mon window will function fine, but none of the Tcl/Tk dialogues will work, failing with an error message complaining either about Wish not behaving as expected, or a &amp;quot;Bad Atom&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Documentation]]&lt;/div&gt;</summary>
		<author><name>⚠️Harrikoo</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_PHP&amp;diff=2956</id>
		<title>GRASS and PHP</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_PHP&amp;diff=2956"/>
		<updated>2006-11-04T23:22:58Z</updated>

		<summary type="html">&lt;p&gt;⚠️Harrikoo: /* Redirecting STDOUT and STDERR */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Running Grass modules through an Webserver==&lt;br /&gt;
&lt;br /&gt;
For some reasons, you may want to call Grass modules within a html page instead of using the command line or a GUI. One way - among others - is to execute them out of a php script.&lt;br /&gt;
&lt;br /&gt;
In the following, a few notes how to procceed for writing your own code:&lt;br /&gt;
&lt;br /&gt;
===Check your php installation===&lt;br /&gt;
&lt;br /&gt;
Save this code snipped in your server directory under the filename &amp;quot;doihavephp.php&amp;quot; and call it with a web browser:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
   phpinfo();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There you will see detailed informations upon your server's php installation. If you see nothing, please check http://www.php.net for details &lt;br /&gt;
how to get and install php on your machine.&lt;br /&gt;
&lt;br /&gt;
===Define the environment settings===&lt;br /&gt;
&lt;br /&gt;
By default, there are only a few variables set in the server environment. Save the following snippet under &amp;quot;env.php&amp;quot; and see what is set &lt;br /&gt;
as default values for your server. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
//enable all error messages&lt;br /&gt;
error_reporting(E_ALL);&lt;br /&gt;
//print a line of text as a header for the following output&lt;br /&gt;
echo &amp;quot;&amp;lt;hr&amp;gt;env:&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
//execute the env command and redirect the output&lt;br /&gt;
$handle = popen('&amp;quot;env&amp;quot; 2&amp;gt;&amp;amp;1', 'r');&lt;br /&gt;
//wait a while for the results. this is not clean, but works for the first attempt&lt;br /&gt;
sleep(&amp;quot;1&amp;quot;);&lt;br /&gt;
//collect the response &lt;br /&gt;
$read = fread($handle, 4096);&lt;br /&gt;
//print the response - if response is incomplete, increment the sleep delay&lt;br /&gt;
echo $read;&lt;br /&gt;
//don't forget to close the handle&lt;br /&gt;
pclose($handle);&lt;br /&gt;
echo &amp;quot;&amp;lt;br&amp;gt;done.&amp;lt;hr&amp;gt;&amp;quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note''': Please be careful when modifying environment variables permanent in files like /etc/bashrc. You may cause by accident security leaks. Please check with your IT manager how to grant security when your machine is visible to the internet.&lt;br /&gt;
&lt;br /&gt;
The environment variables are set by using the *&amp;lt;verbatim&amp;gt;putenv(&amp;quot;VARIABLE&amp;quot;)&amp;lt;/verbatim&amp;gt;* command. They are only valid during the runtime of the actual script, so you have to send the full set for each request.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
error_reporting(E_ALL);&lt;br /&gt;
putenv(&amp;quot;GRASS_WIDTH=900&amp;quot;);&lt;br /&gt;
echo &amp;quot;&amp;lt;hr&amp;gt;env:&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
$handle = popen('&amp;quot;env&amp;quot; 2&amp;gt;&amp;amp;1', 'r');&lt;br /&gt;
sleep(&amp;quot;1&amp;quot;);&lt;br /&gt;
$read = fread($handle, 4096);&lt;br /&gt;
echo $read;&lt;br /&gt;
pclose($handle);&lt;br /&gt;
echo &amp;quot;&amp;lt;br&amp;gt;done.&amp;lt;hr&amp;gt;&amp;quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The list shows some environment variables used by GRASS modules. Please note, that the content has to be adapted to meet your system's specific setup and that it may be incomplete or partially false in some combinations. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Variable !! Value !! Note&lt;br /&gt;
|-&lt;br /&gt;
| GISBASE || /usr/local/grass-6.1.cvs || &amp;quot;...where the happy little creatures hide...&amp;quot; (Bob Ross)&lt;br /&gt;
|-&lt;br /&gt;
| LD_LIBRARY_PATH || /usr/lib:/usr/local/grass-6.1.cvs/lib:/usr.. || path to ALL required libraries&lt;br /&gt;
|-&lt;br /&gt;
| GISRC || /gd/.grassrc6_php || Grass resource file -please see related paragraph below&lt;br /&gt;
|-&lt;br /&gt;
| HOME || /tmp ||&lt;br /&gt;
|-&lt;br /&gt;
| GRASS_PERL || /usr/bin/perl ||&lt;br /&gt;
|-&lt;br /&gt;
| GIS_LOCK || $$ ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Glynn clarified regarding GRASS_LD_LIBRARY_PATH:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You need to set LD_LIBRARY_PATH. GRASS_LD_LIBRARY_PATH is merely a saved copy so that the value can be restored if LD_LIBRARY_PATH is reset due to running a setuid/setgid executable (e.g. xterm). LD_LIBRARY_PATH is what the Linux loader actually uses to locate shared libraries.&lt;br /&gt;
&lt;br /&gt;
===Redirecting STDOUT and STDERR===&lt;br /&gt;
&lt;br /&gt;
When calling a function, you may either collect the output in a handle  as shown in the example before or redirect it in a text file. The syntax for redirection is:&lt;br /&gt;
&lt;br /&gt;
'''system(&amp;quot;g.version &amp;gt; version.txt 2&amp;gt; version_err.txt&amp;quot;);'''&lt;br /&gt;
&lt;br /&gt;
Another option is to use PHP function [http://www.php.net/proc_open proc_open()] which gives you means to use stdin, stdout and stderr in a flexible fashion. It is especially handy if you want to feed data to a GRASS module.&lt;br /&gt;
&lt;br /&gt;
===Deleting prior output files===&lt;br /&gt;
&lt;br /&gt;
Remove output files immediately after use or before rewriting them to ensure that you will not work with old stuff in case of troubles.&lt;br /&gt;
&lt;br /&gt;
'''system(&amp;quot;rm -f version.txt&amp;quot;);''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''system(&amp;quot;rm -f version_err.txt&amp;quot;);'''&lt;br /&gt;
&lt;br /&gt;
===The GRASS Resource File===&lt;br /&gt;
&lt;br /&gt;
You may copy your .grassrc6 file to your script directory and e.g. name it .grassrc6_php. It contains the follwing lines and has to be adapted to fit into your setup:&lt;br /&gt;
&lt;br /&gt;
'''file .grassrc6_php''' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
GISDBASE: /gd&lt;br /&gt;
GRASS_GUI: text&lt;br /&gt;
MAPSET: etopo5&lt;br /&gt;
LOCATION_NAME: smallworld&lt;br /&gt;
MONITOR: PNG&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Access Rights===&lt;br /&gt;
&lt;br /&gt;
'''The Problem''':&lt;br /&gt;
&lt;br /&gt;
I can't get outside a shell access to a mapset even when calling in advance g.access with grant for both user and group. When chowning the entire location directory to user www-data, it works, but then there is no longer access from the grass shell. &lt;br /&gt;
&lt;br /&gt;
'''Glynn wrote''': You can't select a mapset as the current mapset unless you actually own it. Having write permission isn't sufficient.&lt;br /&gt;
&lt;br /&gt;
This check is implemented in G__mapset_permissions() and G__mapset_permissions2() in lib/gis/mapset_msc.c. &lt;br /&gt;
You will have to modify those functions to disable the check if you want to be able to modify mapsets which you don't own.&lt;br /&gt;
&lt;br /&gt;
If your web application only reads the data, you can create a single mapset directory owned by the account under which the PHP script runs,&lt;br /&gt;
then either use g.mapsets or explicit map@mapset references to access maps in other mapsets.&lt;br /&gt;
&lt;br /&gt;
====One working solution====&lt;br /&gt;
&lt;br /&gt;
Thist works at least on Debian with Apache. Contrary to the common settings where Apache is running as user 'nobody', in Debian, the Apache user is 'www-data' and it belongs to the group 'www-data':&lt;br /&gt;
&lt;br /&gt;
Make sure the permissions of your location directory include the group write permission, and your username also belongs to the group ''www-data''.&lt;br /&gt;
&lt;br /&gt;
As ''www-data'' (In principle: '&amp;lt;code&amp;gt;su www-data&amp;lt;/code&amp;gt;' as ''root''; in practice, also '&amp;lt;code&amp;gt;sudo su www-data&amp;lt;/code&amp;gt;' if your username has the necessary rights.) run &amp;lt;code&amp;gt;grass&amp;lt;/code&amp;gt;. In the location window, give the location of your data (&amp;lt;tt&amp;gt;/home/johndoe/grass&amp;lt;/tt&amp;gt; or whatever). Now all the mapsets you create will have the necessary rights properly set up both in the filesystem as in GRASS. &lt;br /&gt;
&lt;br /&gt;
In the same way, you can also set up the database access rights.&lt;br /&gt;
&lt;br /&gt;
This approach has the nice feature, that you don't have to worry about the &amp;lt;tt&amp;gt;.grassrc6&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;.grasslogin6&amp;lt;/tt&amp;gt; files; the right data will go to the right place automatically, most probably in &amp;lt;tt&amp;gt;/var/www&amp;lt;/tt&amp;gt;, depending where the $HOME setting of Apache points to.&lt;br /&gt;
&lt;br /&gt;
--[[User:Harrikoo|Harri]] 18:44, 4 November 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
===Resources and examples===&lt;br /&gt;
&lt;br /&gt;
Earthquake epicenters dynamically inserted (see source code link there at page bottom): http://grass.itc.it/spearfish/php_grass_earthquakes.php&lt;br /&gt;
&lt;br /&gt;
A simple GRASS Map on the fly: http://grass.itc.it/spearfish/php_grassmap.php&lt;br /&gt;
&lt;br /&gt;
related e-mails: http://grass.itc.it/pipermail/grass5/2004-August/015106.html&lt;br /&gt;
&lt;br /&gt;
Many thanks to Glynn Clements, Markus Neteler and Sharyn Namnath for code and help!&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Linking to other languages]]&lt;/div&gt;</summary>
		<author><name>⚠️Harrikoo</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_PHP&amp;diff=2955</id>
		<title>GRASS and PHP</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_PHP&amp;diff=2955"/>
		<updated>2006-11-04T23:18:32Z</updated>

		<summary type="html">&lt;p&gt;⚠️Harrikoo: /* One working solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Running Grass modules through an Webserver==&lt;br /&gt;
&lt;br /&gt;
For some reasons, you may want to call Grass modules within a html page instead of using the command line or a GUI. One way - among others - is to execute them out of a php script.&lt;br /&gt;
&lt;br /&gt;
In the following, a few notes how to procceed for writing your own code:&lt;br /&gt;
&lt;br /&gt;
===Check your php installation===&lt;br /&gt;
&lt;br /&gt;
Save this code snipped in your server directory under the filename &amp;quot;doihavephp.php&amp;quot; and call it with a web browser:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
   phpinfo();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There you will see detailed informations upon your server's php installation. If you see nothing, please check http://www.php.net for details &lt;br /&gt;
how to get and install php on your machine.&lt;br /&gt;
&lt;br /&gt;
===Define the environment settings===&lt;br /&gt;
&lt;br /&gt;
By default, there are only a few variables set in the server environment. Save the following snippet under &amp;quot;env.php&amp;quot; and see what is set &lt;br /&gt;
as default values for your server. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
//enable all error messages&lt;br /&gt;
error_reporting(E_ALL);&lt;br /&gt;
//print a line of text as a header for the following output&lt;br /&gt;
echo &amp;quot;&amp;lt;hr&amp;gt;env:&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
//execute the env command and redirect the output&lt;br /&gt;
$handle = popen('&amp;quot;env&amp;quot; 2&amp;gt;&amp;amp;1', 'r');&lt;br /&gt;
//wait a while for the results. this is not clean, but works for the first attempt&lt;br /&gt;
sleep(&amp;quot;1&amp;quot;);&lt;br /&gt;
//collect the response &lt;br /&gt;
$read = fread($handle, 4096);&lt;br /&gt;
//print the response - if response is incomplete, increment the sleep delay&lt;br /&gt;
echo $read;&lt;br /&gt;
//don't forget to close the handle&lt;br /&gt;
pclose($handle);&lt;br /&gt;
echo &amp;quot;&amp;lt;br&amp;gt;done.&amp;lt;hr&amp;gt;&amp;quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note''': Please be careful when modifying environment variables permanent in files like /etc/bashrc. You may cause by accident security leaks. Please check with your IT manager how to grant security when your machine is visible to the internet.&lt;br /&gt;
&lt;br /&gt;
The environment variables are set by using the *&amp;lt;verbatim&amp;gt;putenv(&amp;quot;VARIABLE&amp;quot;)&amp;lt;/verbatim&amp;gt;* command. They are only valid during the runtime of the actual script, so you have to send the full set for each request.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
error_reporting(E_ALL);&lt;br /&gt;
putenv(&amp;quot;GRASS_WIDTH=900&amp;quot;);&lt;br /&gt;
echo &amp;quot;&amp;lt;hr&amp;gt;env:&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
$handle = popen('&amp;quot;env&amp;quot; 2&amp;gt;&amp;amp;1', 'r');&lt;br /&gt;
sleep(&amp;quot;1&amp;quot;);&lt;br /&gt;
$read = fread($handle, 4096);&lt;br /&gt;
echo $read;&lt;br /&gt;
pclose($handle);&lt;br /&gt;
echo &amp;quot;&amp;lt;br&amp;gt;done.&amp;lt;hr&amp;gt;&amp;quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The list shows some environment variables used by GRASS modules. Please note, that the content has to be adapted to meet your system's specific setup and that it may be incomplete or partially false in some combinations. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Variable !! Value !! Note&lt;br /&gt;
|-&lt;br /&gt;
| GISBASE || /usr/local/grass-6.1.cvs || &amp;quot;...where the happy little creatures hide...&amp;quot; (Bob Ross)&lt;br /&gt;
|-&lt;br /&gt;
| LD_LIBRARY_PATH || /usr/lib:/usr/local/grass-6.1.cvs/lib:/usr.. || path to ALL required libraries&lt;br /&gt;
|-&lt;br /&gt;
| GISRC || /gd/.grassrc6_php || Grass resource file -please see related paragraph below&lt;br /&gt;
|-&lt;br /&gt;
| HOME || /tmp ||&lt;br /&gt;
|-&lt;br /&gt;
| GRASS_PERL || /usr/bin/perl ||&lt;br /&gt;
|-&lt;br /&gt;
| GIS_LOCK || $$ ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Glynn clarified regarding GRASS_LD_LIBRARY_PATH:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You need to set LD_LIBRARY_PATH. GRASS_LD_LIBRARY_PATH is merely a saved copy so that the value can be restored if LD_LIBRARY_PATH is reset due to running a setuid/setgid executable (e.g. xterm). LD_LIBRARY_PATH is what the Linux loader actually uses to locate shared libraries.&lt;br /&gt;
&lt;br /&gt;
===Redirecting STDOUT and STDERR===&lt;br /&gt;
&lt;br /&gt;
When calling a function, you may either collect the output in a handle  as shown in the example before or redirect it in a text file. The syntax for redirection is:&lt;br /&gt;
&lt;br /&gt;
'''system(&amp;quot;g.version &amp;gt; version.txt 2&amp;gt; version_err.txt&amp;quot;);'''&lt;br /&gt;
&lt;br /&gt;
===Deleting prior output files===&lt;br /&gt;
&lt;br /&gt;
Remove output files immediately after use or before rewriting them to ensure that you will not work with old stuff in case of troubles.&lt;br /&gt;
&lt;br /&gt;
'''system(&amp;quot;rm -f version.txt&amp;quot;);''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''system(&amp;quot;rm -f version_err.txt&amp;quot;);'''&lt;br /&gt;
&lt;br /&gt;
===The GRASS Resource File===&lt;br /&gt;
&lt;br /&gt;
You may copy your .grassrc6 file to your script directory and e.g. name it .grassrc6_php. It contains the follwing lines and has to be adapted to fit into your setup:&lt;br /&gt;
&lt;br /&gt;
'''file .grassrc6_php''' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
GISDBASE: /gd&lt;br /&gt;
GRASS_GUI: text&lt;br /&gt;
MAPSET: etopo5&lt;br /&gt;
LOCATION_NAME: smallworld&lt;br /&gt;
MONITOR: PNG&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Access Rights===&lt;br /&gt;
&lt;br /&gt;
'''The Problem''':&lt;br /&gt;
&lt;br /&gt;
I can't get outside a shell access to a mapset even when calling in advance g.access with grant for both user and group. When chowning the entire location directory to user www-data, it works, but then there is no longer access from the grass shell. &lt;br /&gt;
&lt;br /&gt;
'''Glynn wrote''': You can't select a mapset as the current mapset unless you actually own it. Having write permission isn't sufficient.&lt;br /&gt;
&lt;br /&gt;
This check is implemented in G__mapset_permissions() and G__mapset_permissions2() in lib/gis/mapset_msc.c. &lt;br /&gt;
You will have to modify those functions to disable the check if you want to be able to modify mapsets which you don't own.&lt;br /&gt;
&lt;br /&gt;
If your web application only reads the data, you can create a single mapset directory owned by the account under which the PHP script runs,&lt;br /&gt;
then either use g.mapsets or explicit map@mapset references to access maps in other mapsets.&lt;br /&gt;
&lt;br /&gt;
====One working solution====&lt;br /&gt;
&lt;br /&gt;
Thist works at least on Debian with Apache. Contrary to the common settings where Apache is running as user 'nobody', in Debian, the Apache user is 'www-data' and it belongs to the group 'www-data':&lt;br /&gt;
&lt;br /&gt;
Make sure the permissions of your location directory include the group write permission, and your username also belongs to the group ''www-data''.&lt;br /&gt;
&lt;br /&gt;
As ''www-data'' (In principle: '&amp;lt;code&amp;gt;su www-data&amp;lt;/code&amp;gt;' as ''root''; in practice, also '&amp;lt;code&amp;gt;sudo su www-data&amp;lt;/code&amp;gt;' if your username has the necessary rights.) run &amp;lt;code&amp;gt;grass&amp;lt;/code&amp;gt;. In the location window, give the location of your data (&amp;lt;tt&amp;gt;/home/johndoe/grass&amp;lt;/tt&amp;gt; or whatever). Now all the mapsets you create will have the necessary rights properly set up both in the filesystem as in GRASS. &lt;br /&gt;
&lt;br /&gt;
In the same way, you can also set up the database access rights.&lt;br /&gt;
&lt;br /&gt;
This approach has the nice feature, that you don't have to worry about the &amp;lt;tt&amp;gt;.grassrc6&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;.grasslogin6&amp;lt;/tt&amp;gt; files; the right data will go to the right place automatically, most probably in &amp;lt;tt&amp;gt;/var/www&amp;lt;/tt&amp;gt;, depending where the $HOME setting of Apache points to.&lt;br /&gt;
&lt;br /&gt;
--[[User:Harrikoo|Harri]] 18:44, 4 November 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
===Resources and examples===&lt;br /&gt;
&lt;br /&gt;
Earthquake epicenters dynamically inserted (see source code link there at page bottom): http://grass.itc.it/spearfish/php_grass_earthquakes.php&lt;br /&gt;
&lt;br /&gt;
A simple GRASS Map on the fly: http://grass.itc.it/spearfish/php_grassmap.php&lt;br /&gt;
&lt;br /&gt;
related e-mails: http://grass.itc.it/pipermail/grass5/2004-August/015106.html&lt;br /&gt;
&lt;br /&gt;
Many thanks to Glynn Clements, Markus Neteler and Sharyn Namnath for code and help!&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Linking to other languages]]&lt;/div&gt;</summary>
		<author><name>⚠️Harrikoo</name></author>
	</entry>
	<entry>
		<id>https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_PHP&amp;diff=2953</id>
		<title>GRASS and PHP</title>
		<link rel="alternate" type="text/html" href="https://grasswiki.osgeo.org/w/index.php?title=GRASS_and_PHP&amp;diff=2953"/>
		<updated>2006-11-04T17:44:57Z</updated>

		<summary type="html">&lt;p&gt;⚠️Harrikoo: /* Access Rights */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Running Grass modules through an Webserver==&lt;br /&gt;
&lt;br /&gt;
For some reasons, you may want to call Grass modules within a html page instead of using the command line or a GUI. One way - among others - is to execute them out of a php script.&lt;br /&gt;
&lt;br /&gt;
In the following, a few notes how to procceed for writing your own code:&lt;br /&gt;
&lt;br /&gt;
===Check your php installation===&lt;br /&gt;
&lt;br /&gt;
Save this code snipped in your server directory under the filename &amp;quot;doihavephp.php&amp;quot; and call it with a web browser:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
   phpinfo();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
There you will see detailed informations upon your server's php installation. If you see nothing, please check http://www.php.net for details &lt;br /&gt;
how to get and install php on your machine.&lt;br /&gt;
&lt;br /&gt;
===Define the environment settings===&lt;br /&gt;
&lt;br /&gt;
By default, there are only a few variables set in the server environment. Save the following snippet under &amp;quot;env.php&amp;quot; and see what is set &lt;br /&gt;
as default values for your server. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
//enable all error messages&lt;br /&gt;
error_reporting(E_ALL);&lt;br /&gt;
//print a line of text as a header for the following output&lt;br /&gt;
echo &amp;quot;&amp;lt;hr&amp;gt;env:&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
//execute the env command and redirect the output&lt;br /&gt;
$handle = popen('&amp;quot;env&amp;quot; 2&amp;gt;&amp;amp;1', 'r');&lt;br /&gt;
//wait a while for the results. this is not clean, but works for the first attempt&lt;br /&gt;
sleep(&amp;quot;1&amp;quot;);&lt;br /&gt;
//collect the response &lt;br /&gt;
$read = fread($handle, 4096);&lt;br /&gt;
//print the response - if response is incomplete, increment the sleep delay&lt;br /&gt;
echo $read;&lt;br /&gt;
//don't forget to close the handle&lt;br /&gt;
pclose($handle);&lt;br /&gt;
echo &amp;quot;&amp;lt;br&amp;gt;done.&amp;lt;hr&amp;gt;&amp;quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note''': Please be careful when modifying environment variables permanent in files like /etc/bashrc. You may cause by accident security leaks. Please check with your IT manager how to grant security when your machine is visible to the internet.&lt;br /&gt;
&lt;br /&gt;
The environment variables are set by using the *&amp;lt;verbatim&amp;gt;putenv(&amp;quot;VARIABLE&amp;quot;)&amp;lt;/verbatim&amp;gt;* command. They are only valid during the runtime of the actual script, so you have to send the full set for each request.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
error_reporting(E_ALL);&lt;br /&gt;
putenv(&amp;quot;GRASS_WIDTH=900&amp;quot;);&lt;br /&gt;
echo &amp;quot;&amp;lt;hr&amp;gt;env:&amp;lt;br&amp;gt;&amp;quot;;&lt;br /&gt;
$handle = popen('&amp;quot;env&amp;quot; 2&amp;gt;&amp;amp;1', 'r');&lt;br /&gt;
sleep(&amp;quot;1&amp;quot;);&lt;br /&gt;
$read = fread($handle, 4096);&lt;br /&gt;
echo $read;&lt;br /&gt;
pclose($handle);&lt;br /&gt;
echo &amp;quot;&amp;lt;br&amp;gt;done.&amp;lt;hr&amp;gt;&amp;quot;;&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The list shows some environment variables used by GRASS modules. Please note, that the content has to be adapted to meet your system's specific setup and that it may be incomplete or partially false in some combinations. &lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Variable !! Value !! Note&lt;br /&gt;
|-&lt;br /&gt;
| GISBASE || /usr/local/grass-6.1.cvs || &amp;quot;...where the happy little creatures hide...&amp;quot; (Bob Ross)&lt;br /&gt;
|-&lt;br /&gt;
| LD_LIBRARY_PATH || /usr/lib:/usr/local/grass-6.1.cvs/lib:/usr.. || path to ALL required libraries&lt;br /&gt;
|-&lt;br /&gt;
| GISRC || /gd/.grassrc6_php || Grass resource file -please see related paragraph below&lt;br /&gt;
|-&lt;br /&gt;
| HOME || /tmp ||&lt;br /&gt;
|-&lt;br /&gt;
| GRASS_PERL || /usr/bin/perl ||&lt;br /&gt;
|-&lt;br /&gt;
| GIS_LOCK || $$ ||&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
'''Glynn clarified regarding GRASS_LD_LIBRARY_PATH:'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You need to set LD_LIBRARY_PATH. GRASS_LD_LIBRARY_PATH is merely a saved copy so that the value can be restored if LD_LIBRARY_PATH is reset due to running a setuid/setgid executable (e.g. xterm). LD_LIBRARY_PATH is what the Linux loader actually uses to locate shared libraries.&lt;br /&gt;
&lt;br /&gt;
===Redirecting STDOUT and STDERR===&lt;br /&gt;
&lt;br /&gt;
When calling a function, you may either collect the output in a handle  as shown in the example before or redirect it in a text file. The syntax for redirection is:&lt;br /&gt;
&lt;br /&gt;
'''system(&amp;quot;g.version &amp;gt; version.txt 2&amp;gt; version_err.txt&amp;quot;);'''&lt;br /&gt;
&lt;br /&gt;
===Deleting prior output files===&lt;br /&gt;
&lt;br /&gt;
Remove output files immediately after use or before rewriting them to ensure that you will not work with old stuff in case of troubles.&lt;br /&gt;
&lt;br /&gt;
'''system(&amp;quot;rm -f version.txt&amp;quot;);''' &amp;lt;br&amp;gt;&lt;br /&gt;
'''system(&amp;quot;rm -f version_err.txt&amp;quot;);'''&lt;br /&gt;
&lt;br /&gt;
===The GRASS Resource File===&lt;br /&gt;
&lt;br /&gt;
You may copy your .grassrc6 file to your script directory and e.g. name it .grassrc6_php. It contains the follwing lines and has to be adapted to fit into your setup:&lt;br /&gt;
&lt;br /&gt;
'''file .grassrc6_php''' &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
GISDBASE: /gd&lt;br /&gt;
GRASS_GUI: text&lt;br /&gt;
MAPSET: etopo5&lt;br /&gt;
LOCATION_NAME: smallworld&lt;br /&gt;
MONITOR: PNG&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Access Rights===&lt;br /&gt;
&lt;br /&gt;
'''The Problem''':&lt;br /&gt;
&lt;br /&gt;
I can't get outside a shell access to a mapset even when calling in advance g.access with grant for both user and group. When chowning the entire location directory to user www-data, it works, but then there is no longer access from the grass shell. &lt;br /&gt;
&lt;br /&gt;
'''Glynn wrote''': You can't select a mapset as the current mapset unless you actually own it. Having write permission isn't sufficient.&lt;br /&gt;
&lt;br /&gt;
This check is implemented in G__mapset_permissions() and G__mapset_permissions2() in lib/gis/mapset_msc.c. &lt;br /&gt;
You will have to modify those functions to disable the check if you want to be able to modify mapsets which you don't own.&lt;br /&gt;
&lt;br /&gt;
If your web application only reads the data, you can create a single mapset directory owned by the account under which the PHP script runs,&lt;br /&gt;
then either use g.mapsets or explicit map@mapset references to access maps in other mapsets.&lt;br /&gt;
&lt;br /&gt;
====One working solution====&lt;br /&gt;
&lt;br /&gt;
Make sure the permissions of your location directory include the group write permission, and your username also belongs to the group ''www-data''.&lt;br /&gt;
&lt;br /&gt;
As ''www-data'' (In principle: '&amp;lt;code&amp;gt;su www-data&amp;lt;/code&amp;gt;' as ''root''; in practice, also '&amp;lt;code&amp;gt;sudo su www-data&amp;lt;/code&amp;gt;' if your username has the necessary rights.) run &amp;lt;code&amp;gt;grass&amp;lt;/code&amp;gt;. In the location window, give the location of your data (&amp;lt;tt&amp;gt;/home/johndoe/grass&amp;lt;/tt&amp;gt; or whatever). Now all the mapsets you create will have the necessary rights properly set up both in the filesystem as in GRASS. &lt;br /&gt;
&lt;br /&gt;
In the same way, you can also set up the database access rights.&lt;br /&gt;
&lt;br /&gt;
This approach has the nice feature, that you don't have to worry about the &amp;lt;tt&amp;gt;.grassrc6&amp;lt;/tt&amp;gt; or &amp;lt;tt&amp;gt;.grasslogin6&amp;lt;/tt&amp;gt; files; the right data will go to the right place automatically, most probably in &amp;lt;tt&amp;gt;/var/www&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
--[[User:Harrikoo|Harri]] 18:44, 4 November 2006 (CET)&lt;br /&gt;
&lt;br /&gt;
===Resources and examples===&lt;br /&gt;
&lt;br /&gt;
Earthquake epicenters dynamically inserted (see source code link there at page bottom): http://grass.itc.it/spearfish/php_grass_earthquakes.php&lt;br /&gt;
&lt;br /&gt;
A simple GRASS Map on the fly: http://grass.itc.it/spearfish/php_grassmap.php&lt;br /&gt;
&lt;br /&gt;
related e-mails: http://grass.itc.it/pipermail/grass5/2004-August/015106.html&lt;br /&gt;
&lt;br /&gt;
Many thanks to Glynn Clements, Markus Neteler and Sharyn Namnath for code and help!&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Linking to other languages]]&lt;/div&gt;</summary>
		<author><name>⚠️Harrikoo</name></author>
	</entry>
</feed>