User Tools

Site Tools


wiki:grasscreatelocation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

wiki:grasscreatelocation [2019/05/16 12:54] (current)
Line 1: Line 1:
 +====== GRASS Create Location using ancillary layer  ======
 +
 +===== Execute GRASS commands while beeing in GRASS   =====
 +
 +Create a location in a new grass database using a referenced dataset.\\
 +\\
 +Create a new GrassDataBase and copy the input.tif ​
 +<code bash>
 +rm -rf ~/​ost4sem/​grassdbnew/​
 +mkdir ~/​ost4sem/​grassdbnew/​
 +cp ~/​ost4sem/​exercise/​basic_adv_gdalogr/​input.tif ~/​ost4sem/​grassdbnew/​input.tif
 +</​code>​
 +
 +Define a projection to the input.tif
 +
 +<code bash>
 +cd ~/​ost4sem/​grassdbnew/​
 +gdalwarp ​  ​-t_srs EPSG:​4326 ​ -s_srs EPSG:​4326 ​ input.tif input_proj.tif
 +</​code>​
 +
 +Run the grass74 command ​ which creates the newlocation based on the input_proj.tif ​
 +
 +<code bash>
 +rm -rf ~/​ost4sem/​grassdbnew/​newlocation
 +grass74 -text -c input_proj.tif newlocation ~/​ost4sem/​grassdbnew ​
 +</​code>​
 +
 +
 +<code bash>
 +r.in.gdal input=input_proj.tif ​ output=input_proj
 +</​code>​
 +
 +import the date
 +
 +<code bash>
 +for file in *.tif 
 +filename=$(basename $file .tif)
 +r.in.gdal input=$file.tif ​ output=$file
 +done
 +</​code>​
 +
 +
 +===== Execute GRASS commands from BASH without enter in GRASS =====
 +
 +
 +<code bash>
 +cd ~/​ost4sem/​grassdbnew/​
 +rm -rf ~/​ost4sem/​grassdbnew/​newlocation
 +grass74 -text -c input_proj.tif ​ -e ~/​ost4sem/​grassdbnew/​newlocation ​
 +grass74 ~/​ost4sem/​grassdbnew/​newlocation/​PERMANENT/​ --exec r.external input=input_proj.tif ​ output=input_proj
 +grass74 ~/​ost4sem/​grassdbnew/​newlocation/​PERMANENT/​ --exec r.info input_proj
 +
 +</​code>​
  
wiki/grasscreatelocation.txt ยท Last modified: 2019/05/16 12:54 (external edit)