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:

v.in.ogr dsn=. layer=soilsa_a_xxx output=boundary

Raster Import

  • Import a DOQQ file from the current directory:

r.in.gdal 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
665015|4036139|100
659998|4039460|123
659651|4039686|244
659466|4039621|400
#-----
v.in.ascii -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 | v.in.ascii 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...

v.in.gpsbabel -t in=/dev/ttyS0 out=gps_tracks format=garmin