[GRASS-user] g.region (was v.to.rast conversion)

Markus Metz markus.metz.giswork at googlemail.com
Wed Dec 16 09:21:33 EST 2009


Hi,

Giacomo Piva wrote:
> Hi Markus,
> I'm not using the GUI because I need to use GRASS as automated tool to 
> convert a shape file to a raster in GTIFF.
The GUI is good to develop and debug the script before you create an 
automated tool that may produce bogus results.
> I tried to do what you have explained in many ways but without success.
>
> I know that I have to execute something like:
> v.in.ogr ...
> v.to.rast ...
> r.out.gdal ...
>
> But the v.in.ogr returns the g.region error also with the location= 
> option.
Then try a valid location to start with, as explained by Glynn. I think 
you can use any valid location, also one of the sample datasets. When 
using an existing valid location, it should be enough to give the 
location name and mapset name as in your script. Then do v.in.ogr -oe 
location=$LOCATION
That obviously only works properly if there is a *.prj file accompanying 
the *.shp file, otherwise you end up with a xy location. In the absence 
of a *.prj file you must either ask the authors of the shapefile or 
guess and manually create the location with the correct projection info.

Markus M

>
> I tried to do another operation (maybe simpler), like reading a raster 
> image and get information on the region, diong:
>
> r.in.gdal -o -e input=$HOME/raster.tif output=grass_rast 
> location=$LOCATION
>
> Then setting the new location (as you suggested) and running the g.region
>
> g.region -p
>
> and this is the output:
>
>
> Location <test> created
> 100%
> r.in.gdal complete. Raster map <grass_rast.1> created.
> Copying 144 GCPS in points file for <grass_rast>
> GCPs have the following OpenGIS WKT Coordinate System::
> GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS
> 84",6378137,298.2572235629972,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]] 
>
> projection: 0 (x,y)
> zone:       0
> north:      2030
> south:      0
> west:       0
> east:       1354
> nsres:      1
> ewres:      1
> rows:       2030
> cols:       1354
> cells:      2748620
>
> It seems to work properly...
>
> Why I can't run the v.in.ogr?
>
> Thank you for help.
>
> Markus Metz wrote:
>> Hi,
>>
>> According to the grass book, the v.in.ogr command should include the 
>> location option:
>> v.in.ogr -o -e dsn=./test_data/test_data.shp output=grass_map 
>> location=$LOCATION
>>
>> then go to the newly created location (set the environment variables 
>> accordingly and update .grassrc6), set the region extends and 
>> resolution to your demands, run v.to.rast, then r.out.gdal.
>>
>> IMHO, it is easier to use the GUI.
>>
>> Hope that helps,
>>
>> Markus M
>>


More information about the grass-user mailing list