[GRASS-user] Export the conversion from Vector to Raster

Kim Besson kimbesson1981 at gmail.com
Fri May 7 05:13:31 EDT 2010


Greetings
This is probably a very dumb thing but I'm having a few difficulties doing
this. I have an SHAPEFILE with classification polygons. And I need to
Convert to raster (e.g. TIF) So I thought of using GRASS (of course)

1- Define region with a Landsat image used to create those Training areas
outside GRASS
2- Run v.in.gor
v.in.ogr -o dsn=C:\Data\GISDataBase\training_data.shp output=train00
Over-riding projection check
Layer: training_data
Default driver / database set to:
driver: dbf
database: $GISDBASE/$LOCATION_NAME/$MAPSET/dbf/
Importanto feições do mapa 448...
-----------------------------------------------------
Building topology for vector map <train00>...
Registering primitives...
448 primitives registered
2903 vertices registered
Building areas...
448 areas built
448 isles built
Attaching islands...
Attaching centroids...
Number of nodes: 448
Number of primitives: 448
Number of points: 0
Number of lines: 0
Number of boundaries: 448
Number of centroids: 0
Number of areas: 448
Number of isles: 448
Number of areas without centroid: 448
-----------------------------------------------------
Cleaning polygons, result is not guaranteed!
Building topology for vector map <train00>...
Number of nodes: 448
Number of primitives: 448
Number of points: 0
Number of lines: 0
Number of boundaries: 448
Number of centroids: 0
Number of areas: -
Number of isles: -
-----------------------------------------------------
Break polygons:
-----------------------------------------------------
Remove duplicates:
-----------------------------------------------------
Break boundaries:
-----------------------------------------------------
Remove duplicates:
-----------------------------------------------------
Clean boundaries at nodes:
-----------------------------------------------------
Change dangles to lines:
-----------------------------------------------------
Remove bridges:
-----------------------------------------------------
Building topology for vector map <train00>...
Building areas...
448 areas built
448 isles built
Attaching islands...
Number of nodes: 448
Number of primitives: 448
Number of points: 0
Number of lines: 0
Number of boundaries: 448
Number of centroids: 0
Number of areas: 448
Number of isles: 448
Number of areas without centroid: 448
Layer: training_data
-----------------------------------------------------
-----------------------------------------------------
Building topology for vector map <train00>...
Registering primitives...
896 primitives registered
3351 vertices registered
Building areas...
448 areas built
448 isles built
Attaching islands...
Attaching centroids...
Number of nodes: 896
Number of primitives: 896
Number of points: 0
Number of lines: 0
Number of boundaries: 448
Number of centroids: 448
Number of areas: 448
Number of isles: 448
-----------------------------------------------------
448 input polygons
Total area: 6.159110e+006 (448 areas)
Overlapping area: 0.000000e+000 (0 areas)
Area without category: 0.000000e+000 (0 areas)

3- It created a vectorial train00. When I open it at GRASS and overlays it
with my landsat images they MATCH...
4- I want to create a RASTER exacly with the same characteristics as my
landsat images but using Class Field as Raster values. I mean, the pixels
inside polygons with class value 12 will have a vlue of 12.
Reading GRASS book I decided to use v.to.rast
v.to.rast input=train00 at PERMANENT output=train_raster00 type=area
column=Class labelcolumn=cat
Loading data...
Pass 1 of 2:
Reading areas...
Reading features...
Writing raster map...
Pass 2 of 2:
Reading areas...
Writing raster map...
Converted areas: 448 of 448
Converted points/lines: 0 of 0
v.to.rast complete.

5- Open train_raster00 and it seems to be Ok when comparing with Vectorial
6- Metadata from is train_raster00
 |   Type of Map:  raster               Number of Categories: 0
  |
 |   Data Type:    CELL
  |
 |   Rows:         7109
  |
 |   Columns:      7662
  |
 |   Total Cells:  54469158
  |
 |        Projection: x,y
  |
 |            N: 23020.21492744    S: -190249.78507256   Res:    30
  |
 |            E: 177696.83076767    W: -52163.16923233   Res:    30
  |
 |   Range of data:    min = 1  max = 17
 |
And Metadata from Landsat is:
|   Type of Map:  raster               Number of Categories: 0
|
 |   Data Type:    CELL
  |
 |   Rows:         7109
  |
 |   Columns:      7662
  |
 |   Total Cells:  54469158
  |
 |        Projection: x,y
  |
 |            N: 23020.21492744    S: -190249.78507256   Res:    30
  |
 |            E: 177696.83076767    W: -52163.16923233   Res:    30
  |
 |   Range of data:    min = 0  max = 255
  |

So it maches :)

7- Now, export this raster.Since I want a Geotiff I used:
r.out.tiff input=train_raster00 at PERMANENT output=trainraster00a
If I do gdalinfo to the exported file I get:river: GTiff/GeoTIFF
Files: /mnt/GIS/trainraster00a.tif
Size is 7662, 7109
Coordinate System is `'
Image Structure Metadata:
  INTERLEAVE=PIXEL
Corner Coordinates:
Upper Left  (    0.0,    0.0)
Lower Left  (    0.0, 7109.0)
Upper Right ( 7662.0,    0.0)
Lower Right ( 7662.0, 7109.0)
Center      ( 3831.0, 3554.5)
Band 1 Block=7662x1 Type=Byte, ColorInterp=Red
Band 2 Block=7662x1 Type=Byte, ColorInterp=Green
Band 3 Block=7662x1 Type=Byte, ColorInterp=Blue

The Size is OK but the Geo information was wipped out
And Why does it create 3 bands? I only need 1 band with Class values.
Can anyone point me out what am I doing wrong?

Thanks
Best regards
Kim~
Sorry for the long EMAIL but I really need to explain what I am doing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20100507/1b53826b/attachment-0001.html


More information about the grass-user mailing list