Get started with GRASS - international tutorial

Helena Mitasova and Markus Neteler

Download GRASS GIS

Download ready to use GRASS data:
North Carolina, USA
some other place
some other country

Comment - international data set for raster data should be straightforward but I see problem with vector data attributes - they need to have the same column names for the tutorial to work. Can this be done - see e.g. schools or streets - we can have just 3-4 attributes with common names, but we need to find out what those are. I will then add more vector examples

Before starting with GRASS it is important to understand that GRASS uses the concept of LOCATION, MAPSET, region to support efficient analysis and modeling without the need to subset and resample data. LOCATION is a project that has common coordinate system. Each LOCATION can have several MAPSETS, one is called PERMANENT to store baseline data, others are set by users. You can modify the data only in your current MAPSET, but you can view or copy data from other MAPSETS.

    # start GRASS
    grass64

    # in startup pannel
    # for GIS data directory use path to datasets
    # LOCATION select gisdemo_yourplace
    # MAPSET create new mapset with your name or use user1
    # Enter GRASS

    # list data in the provided database
    g.list rast
    g.list vect

    # find the working coordinate system, spatial extent
    g.proj -p
    g.region -pl

    # copy, rename and remove maps
    #set working region
    g.region central_10m -p
    g.copy rast=landuse,mylanduse
    g.rename rast=mylanduse,mylanduse_30m
    g.remove rast=mylanduse_30m
    # note you don't have permission to remove maps from PERMANENT

    # get information about raster and vector layers
    r.info elevation
    v.info streets
    v.info -c streets

    #display data in 2Da and 3D
    d.mon x0
    d.erase
    d.rast elevation
    nviz elevation vector=roadsmajor point=schools

    #display elevation as raster color map and as shaded map
    d.his h_map=elevation i_map=elevation_shade
    d.vect streets
    d.vect roadsmajor co=red width=2
    d.vect schools icon=basic/circle size=10 fcol=blue
    d.grid size=5000 col=brown
    d.grid -n size=1000
    d.grid -g size=0:02 col=black
    d.legend elevation at=70,15,5,10
    d.barscale at=5,90
    # save the displayed map
    d.out.file mymap

    # query data
    d.what.rast
    d.what.vect -x

    # zoom-in, zoom-out, zoom to map, zoom to region
    d.zoom

    # change colors for raster maps
    g.copy rast=elevation,myelev
    # find out which color tables are available
    r.colors help
    # set the color table to a predefined one, for example bgyr
    r.colors myelev col=bgyr
    d.rast myelev

    # compute zonal statistics: mean elevation for each zipcode
    # compute zonal statistics
    g.region rast=elevation
    r.average base=zipcodes cover=elevation out=elev_avgzip
    d.rast elev_avgzip
    d.vect zipcodes type=boundary

    # use neighborhood operator to compute land use diversity map
    g.region rast=landuse -p
    r.info -t landuse
    r.neighbors landuse out=lu_divers method=diversity size=7
    d.erase
    d.rast.leg lu_divers
    d.vect streets
    r.report lu_divers unit=p

    # find developed areas close to lakes
    g.region central_10m -p
    r.buffer lakes out=lakes_buff dist=60,120,240,500
    d.rast lakes_buff
    r.mapcalc "developed_lake=if(landuse==1 || landuse==2, lakes_buff, null())"
    d.rast developed_lake
    d.vect streets co=grey
    d.rast -o lakes
    # find the total developed area in ha
    r.report -n lakes_buff unit=p,h
    r.report -n developed_lake unit=p,h

    # compute basic topographic parameters
    g.region rast=elevation -p
    r.slope.aspect el=elevation slope=slope asp=aspect pcurv=profcurv tcurv=tancurv
    d.erase
    d.rast.leg slope
    d.rast.leg aspect
    d.rast.leg profcurv
    d.rast.leg tancurv

    # display vector data attributes
    d.vect.thematic -l census column=HOUSEHOLDS nint=6 color=yellow-cyan
    d.vect.thematic -l schools column=CAPACITYTO type=point size=10 nint=6 themetype=graduated_points