Importing Various Types of Vector and Raster Data

Generic data import and export commands rely on the GDAL/OGR library to be installed correctly. If you have installed GRASS via a binary package, chances are that these commands will work fine. If you have compiled GRASS and GDAL from source, and have not re-compiled GDAL with GRASS support then raster export via r.out.gdal will not work. See this page for details.

The following examples assume that all of the input data has been projected to a consistant coordinate system, and that an appropriate GRASS location has been created. Command names are in boldface type, input files are red, and the resulting GRASS data are in green. Figures are provided for additional context, and are referenced by input/output file name in the example code.
Vector Import

  • Import a SSURGO survey boundary polygon shape file from the current directory: dsn=. layer=soilsa_a_xxx output=boundary

Raster Import

  • Import a DOQQ file from the current directory: input=doqq.tif output=doqq

Text File Import

  • Import an ascii file of x,y,z records from a GPS:

#input_file: meters_x | meters_y | meters_z
#----- -z in=input_file output=gps_points

  • Import an ascii file with variable delimiters

# reformat input text file to single-space delimeted
awk '{print $1, $2, $3}' classes/summer_2005/SSC105/maps/pit_locations.xy | fs=" " x=1 y=2 out=ssc105s
# export to ESRI shapefile with projection stored in .prj file
v.out.ogr -e --v type=point in=ssc105s dsn=ssc105s.shp

GPS Import

  • Import track data from a Garmin Serial GPS. Note that gpsbabel will download points in lon/lat WGS84 format. (gpsbabel must be installed). More ideas here... -t in=/dev/ttyS0 out=gps_tracks format=garmin