Grass Tutorial | ||
---|---|---|
<<< Previous | Next >>> |
This chapter aims at giving a newcomer in GRASS a very hands-on introduction in order to give him the opportunity to very quickly take first tentative steps in GRASS. This does not replace a throrough study of the rest of the documentation, but should help relieve the frustrations that many newbies feel at the first contact with GRASS. It will cover GRASS 6.0, so if you have an earlier version, consider upgrading.
This introduction assumes that you have already successfully installed GRASS, but that you have not yet launched a GRASS session successfully. If you haven't installed GRASS, yet, please have a look at the chapter called Download and Install. For newbies, the binary installation is recommended. If you are unfamiliar with the UNIX or GNU/Linux environment, please go to the chapter called Basic UNIX reference first and follow some of the links there.
Before going any further, you will have to create the GRASS database:
Find a place on your disk where you have write access and that has enough diskspace to hold your decompressed data.
Create a subdirectory that will hold the general GRASS database (e.g. "mkdir /data/GRASSDATA" or "mkdir /home/yourlogin/GRASSDATA").
Now you can go on. The following subsections will cover different potential "scenarios", each representative of the situations in which a new user might turn to GRASS:
If you have a GRASS database, either because someone gave you one, or because you downloaded sample data such as the Spearfish sample dataset (see here for other data sets), then see the Section called You have a GRASS database.
If you have a georeferenced data file (raster, vector or sites) and know its geographical projection, its extension, and its resolution (for raster), then see the Section called You have a georeferenced data file, and know its geographical coordinates.
If you have a georeferenced raster file, but do not know its projection, extension, or resolution, then see the Section called You have a georeferenced raster file, but don't know its geographical coordinates.
If you have a non-georeferenced data file (example scanned map), then see the Section called You have a non-georeferenced data file.
Other, see the Section called Other situations
You have a tar ball (*.tgz, *.tar.gz, *.tar) with an already prepared GRASS location. Here are the steps to follow:
Enter the GRASS database directory you created above and untar your data file in there (e.g. "tar xvzf /path/to/where/you/downloaded/yourdatafile.tgz"). This should create a directory containing the sample location (e.g. spearfish60), with several subdirectories, each of these representing a mapset. There should be at least one, called "PERMANENT" (note the names of the others). Don't touch anything in this directory.
Go back to your home directory ("cd") and start GRASS ("grass").
First specify in the Database field the absolute path to the directory you created above (e.g. "/data/GRASSDATA"). You can now choose the location. If you download sampledata, it will be spearfish60. Now, you should see at least PERMANENT in the mapsets list. You can create a new mapset by enter its name in the left field and click on "Create..." button. Select one them on the mapsets list. Click on "Enter GRASS" button.
The GIS Manager should start automatically.
See the chapter called The Most Important Commands to Get Started for the next steps.
You have a file in a georeferenced format (GeoTiff, shape, etc) and have all the information concerning the projection the data is in, its geographical extensions, and, if it is a raster file, its resolution. You will have to create a location according to that information. Assuming that the file is in your home directory, here's what you have to do (if it somewhere else, just change the path to the file when entering the relevant commands)):
Create a new location according to the information you have and the steps described in the chapter called Set-up your location.
Once you have entered GRASS, you can import the file with the appropriate module as described in Part VI in Grass Tutorial. (You can use the graphical user interface for most imports: start it with d.m&).
When you have finished the importation process, see the chapter called The Most Important Commands to Get Started for the next steps.
Someone gave you a geocoded raster file (GeoTiff, shape, etc) or you downloaded it from somewhere, but you have no information as to its geographical projections, its extension, or its resolution. You, therefore, do not know how to create a location that is appropriate for this data. Here's what you can do:
Check here if the format your file is in can be imported and georeferenced by GDAL. If it can't, see if you can convert it to any of the supported formats. If that is not possible, you're out of luck and will have to move on to the Section called Other situations.
Start GRASS ("grass").
Click on "Create New Location".
In the terminal screen you see, enter a name for a temporary location (e.g. "LOCATION: temp"), leave the mapset at its default (your login name) and set the database to the directory you created at the very beginning (e.g. "/data/GRASSDATA").
When told that the "LOCATION (temp) - doesn't exist" and asked whether you would like to create location (temp), you answer "yes, please" (well actually you just press 'y'.)
You press 'y' again pretending that you have all the information listed on the next screen as being absolutely necessary.
When asked to specify the coordinate system, chose 'a' for "x,y" and then 'y' (or just ENTER) for "yes".
Enter a description of your location, such as "temporary x,y location for import", press ENTER and confirm your beautiful title with 'y' or ENTER.
Don't even look at the next screen (entitled "Define the default region"), just press ESC-ENTER to get it out of your sight as quickly as possible. Again, confirm your "choice" with 'y' or ENTER, plus another ENTER to congratulate GRASS for having created your new location.
Don't panic because you've been returned to the very first screen. It's normal. Press ESC-ENTER, and life in GRASS can begin !
You are in a shell that is just like any other UNIX shell, only for the GRASS prompt and some environment variables that have been added (but that you don't have to worry about).
Now we will use the magic of r.in.gdal:[1] in the command line type "r.in.gdal in=RasterFile out=GRASSRaster location=NewLocation", where 'RasterFile' is the name (and, if the file is not in the current directory, the path) of the raster file you want to import, 'GRASSRaster' is the name you want that map to have in GRASS, and 'NewLocation' the name of a new location r.in.gdal will create automatically for the new map, and which will contain all the geographical information (projection, extension, resolution) included in the orginial raster file.
You may also use v.in.ogr instead of r.in.gdalif you have vector data. GRASS need to be build with OGR support to use this command.
If all goes well (i.e. no error messages), you now have to enter the new location just created automatically by r.in.gdal or v.in.ogr. Since you cannot change location within a running GRASS session, you have to leave GRASS ("exit").
Restart GRASS. This time it should come up with the Tcl/Tk welcome window. The window will list the available locations and mapsets in your GRASS-Database. Chose the new location just created by r.in.gdal/v.in.ogr ('NewLocation'), and chose the mapset that is called after your login name. Then click "Use Selection".
Congratulations, you made it (I hope !). Now you can move on to the chapter called The Most Important Commands to Get Started to actually do something with your map.
You scanned a map and now have a non-georeferenced raster file, Or you downloaded a nice PNG file of a political world map from the internet. Or you drew a map of your garden in the GIMP and now want to use it to manage your plantings. In other words, either you do not have the georeferencing information of this map (and it is not included in the file format) or you do not care about projection for your use of the map. This section is for you.
Before going any further though, a word of advice: if you only plan on viewing the map, and not doing any real work concerning geographical *information* (i.e. linking data with geographical coordinates), then maybe GRASS is not the right tool for you. GRASS is a full-fledged GIS, and not a map viewer, and using it just to quickly view some maps would probably be overkill.
Since your map is not georeferenced, you can import it into a simple x,y location, i.e. where the coordinates directly designate pixels on the screen. In order to do so, just follow the steps described in the previous section, up to the r.in.gdal call. However, in this case you will not use the the 'location=' option, but just type: "r.in.gdal in=RasterFile out=GRASSRaster" (you can also use one of the other raster import commands). That's it ! In order to learn how to view your map and do other basic operations, see the chapter called The Most Important Commands to Get Started.
If you have a scanned map and you have access to the geographical information concerning the original paper map, then you should read the chapter called Processing Scanned Maps.
So, you have a file, without much information about it, but you think (or know) it should be georeferenced. For example, someone sent you an ESRI shape file containing a map you would like to work on. Or you received a raster in a binary format that is not supported by the GDAL library. Here are some tips on what you might want to do, depending on the usage you will make of the file:
Ask the person who sent you the maps to give you more information.
Think about the data. What is it displaying (political boundaries of countries, a satellite image of jungle areas, etc), what is its rough geographical extension (the World or your hometown) ? Where does the data come from (NASA, a personal digitization, etc). All these factors might give you a lead about the structure of the data.
Try to load your data into different locations (see the chapter called Set-up your location for the creation of a location) using widely used projection systems for the area your data is supposed to cover. For example, UTM is widely used in North America, while Gauss-Krueger is often used in Europe. A lot of the basic shapefiles given out by ESRI are in latitude-longitude "projection". You might want to try the latter first and see how the data looks. Is it distorted ? Are vector areas not closed ?
You can also start by creating a simple "x,y" location (see the Section called You have a georeferenced raster file, but don't know its geographical coordinates on how to create such a location). Import your data with the appropriate module (see Part VI in Grass Tutorial and then explore it with the commands explained in the chapter called The Most Important Commands to Get Started.
Good luck !
[1] | If you compiled GRASS yourself, be sure to also have installed the GDAL libraries, otherwise r.in.gdal will not work. This is also true for v.in.ogr that require OGR libraries. |
<<< Previous | Home | Next >>> |
GRASS in 10 minutes - Quick Intro for Newbies | Up | The Most Important Commands to Get Started |