| 1 | = Conversion of Vector maps to Raster maps and GeoTiff images using GRASS = |
| 2 | |
| 3 | |
| 4 | 1. Ensure vector maps are in appropriate directory |
| 5 | eg. /tmp/vectors/ |
| 6 | |
| 7 | 2. Check table names present using db.tables |
| 8 | {{{ |
| 9 | db.tables driver=ogr database=/tmp/vectors/ |
| 10 | |
| 11 | outputs (table names in specified directory): |
| 12 | mny98build |
| 13 | mny98lines |
| 14 | mny98roade |
| 15 | mny98water |
| 16 | }}} |
| 17 | |
| 18 | 3. For each table, check column names present using db.columns |
| 19 | {{{ |
| 20 | db.columns table=mny98build driver=ogr database=/tmp/vectors |
| 21 | |
| 22 | outputs (columns in specified table, note duplicate column name): |
| 23 | FNODE_ |
| 24 | TNODE_ |
| 25 | LPOLY_ |
| 26 | RPOLY_ |
| 27 | LENGTH |
| 28 | MNY98BUILD |
| 29 | MNY98BUILD |
| 30 | }}} |
| 31 | |
| 32 | 4. Import vector map using v.in.ogr. Note that if your table has duplicate column names as this example, you will need to rename your columns using the cnames option, the first argument to which is always an extra category field. Note also that for vector maps without a specified projection you must use the -o flag to override the projection check |
| 33 | {{{ |
| 34 | v.in.ogr -o dsn=/tmp/vectors/ output=vector_map_name layer=mny98build \ |
| 35 | cnames=CAT,FNODE_,TNODE_,LPOLY_,RPOLY_,LENGTH_,MNY98BUILD,MNY98BUILD2 --overwrite |
| 36 | }}} |
| 37 | |
| 38 | 5. Patch imported vector layers together into one map using v.patch |
| 39 | {{{ |
| 40 | v.patch input=mny98build,mny98lines,mny98roade,mny98water output=patched_map_name --overwrite |
| 41 | }}} |
| 42 | |
| 43 | 5. Convert to raster map using v.to.rast. Note this converts for the current region only at the current resolution, so be sure that region and resolution are set as desired |
| 44 | {{{ |
| 45 | v.to.rast input=patched_map_name output=raster_map_name use=val value=100 --overwrite |
| 46 | }}} |
| 47 | |
| 48 | 6. Convert to 8-bit GeoTiff using r.out.gdal |
| 49 | {{{ |
| 50 | r.out.gdal input=raster_map_name type=Byte output=Geotiff_file_name.tif |
| 51 | }}} |