[GRASS-user] what is requried when import data to grass?

Micha Silver micha at arava.co.il
Mon Jun 15 05:47:58 EDT 2009


Hi:

I'm cc'ing the GRASS list, since someone else may have additional ideas.


maven apache wrote:

> Hi:
> I have set all the environment variables needed by Grass,so I start 
> run the grass commond.
> ********Here I have set the env and the g in the "g,run" respent a 
> java class to config the grass**********
>   g.run("r.info <http://r.info> map=roads"); // here I intent to 
> test whether I have enter the default grass location(spanish60) or not
>   g.run("g.proj -c georef=d:/kk.tif datumtrans=0 
> location=mainLocation"); // create new location and mapset accord a tiff
>   g.setLocationAndMapSet("mainLocation", "PERMANENT"); //reset the 
> locaton and mapset
>   g.run("r.in.gdal input=d:/kk.tif out=kkTest");
Most likely you will want to add here: g.region rast=kkTest
This insures that the computational region is the same as the imported 
tiff.
If you don't set the region to the raster's extent then you'll get the 
"black blank" image you mentioned below.
>   g.run("r.info <http://r.info> map=kkTest");
>   g.run("r.buffer input=kkTest output=kkout distances=100 units=meters");
>   g.run("r.out.gdal input=kkout format=GTiff 
> output=d:/kkgeotiffTest.tif"); //here I got a black blank image 
> which I can not open it with common image reader
>   g.run("r.out.tiff input=kkout output=d:/kktiffTest.tif 
> compression=none --quiet"); //here I got a buffered image I can see 
> the roads in it with the commo image viewer. I am not sure why? They 
> are all exported to tiff just by two methods..
As far as I know, r.out.tiff is just a simplified version of r.out.gdal. 
When you use r.out.gdal you have more options available, In particular 
there's the "createopt" option, So you can do:
r.out.gdal in=kkout out=d:/kktiffTest,tif 
createopt="INTERLEAVE=PIXEL,TFW=YES"


>  
> The setLocationAndMapSet method:
>  public void setLocationAndMapSet(String nLocation,String nMapset) {
>   String gisRc="grassrc";
>   FileWriter fstream;
>   try {
>    fstream = new java.io.FileWriter(gisRc);
>    BufferedWriter out = new java.io.BufferedWriter(fstream);
>    out.write("LOCATION_NAME: " + nLocation + " \n");
>    out.write("GISDBASE: " + grassDataBase + "\n");
>    out.write("MAPSET: " + nMapset + " \n");
>    out.write("DIGITIZER: none\n");
>    out.write("OVERWRITE: 1\n");
>    out.write("GRASS_GUI: text\n");
>    out.close();
>   } catch (IOException e) {
>    // TODO Auto-generated catch block
>    e.printStackTrace();
>   }
>   this.setEnv(grassPath, null,gisRc,nMapset, nLocation, 
> grassDataBase,grassPath+File.separator+"proj");
>   
>  }
>  
> In any case ,I have make a progrss, ^_^
> I have some extra questions:
> 1)  take the using grass gui for instance,I want to know if user can 
> change its location dynamically or he can only change it by restart 
> the grass ? I just want to know the above method is improveable?
g.mapset is the command to change the location or mapset within a GRASS 
session
> 2) the differedt resut of two differente export way( r.out.gdal  
> r.out.tiff)
See above.
> 3) Can I delete the location using some grass commond? I mean I want 
> to delete the created location and mapset after a user quested is 
> completed.
Just delete the whole location directory.
>  
> Thanks!
Regards,
Micha
>  
> 2009/6/14 Micha Silver <micha at arava.co.il <mailto:micha at arava.co.il>>
>
>     maven apache wrote:
>>
>>          I think you should start this way, and
>>
>>      
>>
>>         work out the string of GRASS commands you will need *before*
>>         you start scripting.
>>
>>     Sorry but I am not exactly know your meaning.
>     I just suggest you start by working out the GRASS commands you
>     will need from *within GRASS*. For example, for the script I sent
>     you earlier, I first started GRASS, then I ran those commands, one
>     by one. This way I can check that the commands are working as I
>     want. Then,  I copied them into the script and, after exiting
>     GRASS, I ran the script.
>
>>      
>>
>>         Then, once you have the workflow running correctly, you can,
>>
>>      
>>
>>         from outside of GRASS,
>>
>>     Also,what?
>     It's very possible to run GRASS commands without the GRASS
>     interface, but you first have to set up the environment: some
>     environ variables and path. The basic example script is a demo how
>     it could be done. Once you have setup those path and environment
>     variables, you can run a script of GRASS commands without starting
>     the interface.
>     Hope that's clearer now...
>     -- 
>     Micha
>>
>>         setup the environment and run that same workflow.
>>
>>
>>     This mail was received via Mail-SeCure System.
>
>
>
> This mail was received via Mail-SeCure System.



More information about the grass-user mailing list