GRASS Short Course - Notes for Part 3: GDAL, OGR and GRASS import

GDAL tools for raster maps:

Raster data preparations:
#Preparation (unfortunately the Spearfish aerial images are published in the
#  proprietary MrSID format: Conversion to GeoTIFF using the
#  non-free 'mrsiddecode' for Linux from www.lizardtech.com:
#mrsiddecode -tif -input i44103d7_a.sid -output i44103d7_a.tif

#Display raster file info:
gdalinfo i44103d6_b.tif

#which formats are supported:
gdalinfo --formats

Assigning a Spatial Reference System (a_srs) to fix the missing raster map projection info (UTM/NAD83):

#EPSG file: /usr/local/share/proj/epsg
gdal_translate -of GTIFF -a_srs '+init=epsg:26913' \
               i44103d6_b.tif i44103d6_b_NAD83.tif

gdalinfo i44103d6_b_NAD83.tif

Reprojecting maps ("warping") to different projection/geodetic datum (UTM/NAD27) to make ready for Spearfish location:

gdalwarp -t_srs '+init=epsg:26713' i44103d6_b_NAD83.tif \
                 i44103d6_b_NAD27.tif

gdalinfo i44103d6_b_NAD27.tif

Spatial subsetting (cut out region):

#                                   W       N       E      S
gdal_translate -of GTiff -projwin 636861 5152686 745617 5054047.5 \
				p192r28_5t19920809_nn1.tif p192r28_subset1.tif

OGR tools for vector maps:

Display vector file info:
ogrinfo buek50.shp
 INFO: Open of 'buek50.shp'
 using driver 'ESRI Shapefile' successful.
 1: buek50 (Polygon)

#To get layer metadata, also specify layer name and '-summary':
ogrinfo -summary buek50.shp buek50

#which formats are supported:
ogrinfo --formats

Assigning a Spatial Reference System (a_srs) to fix the vector map:

ogr2ogr -a_srs '+init=epsg:31463' buek50_GKzone3.shp \
               buek50.shp

ogrinfo -summary buek50_GKzone3.shp buek50_GKzone3

Reprojecting maps to different projection/geodetic datum:

#reprojecting vector maps with 'ogr2ogr' from Gauss-Krüger to UTM/ED50:
# from EPSG file:
#     ED50 / UTM zone 32N
#     <23032> +proj=utm +zone=32 +ellps=intl +units=m +no_defs  no_defs <>

ogr2ogr -t_srs '+init=epsg:23032' buek50_UTM_ED50.shp \
               buek50_GKzone3.shp

ogrinfo -summary buek50_UTM_ED50.shp buek50_UTM_ED50
See 'ogr2ogr -help' for more things you could do.
© 2003 Markus Neteler (neteler AT itc.it)
Back Course HOME
Last change: $Date: 2004-11-25 10:46:31 +0100 (Thu, 25 Nov 2004) $