Country Data Processing

From GRASS-Wiki
Jump to navigation Jump to search

This tutorial describes how to

  • find free data of country on Internet
  • create new GRASS location
  • import found data into GRASS
  • create new vector layers from existing data
  • create labels
  • display map of a country

GRASS Installation

Required elements

Create directory structure required for this tutorial

  • dataset directory
  $ mkdir ~/grass
  • input data directory
  $ mkdir ~/grass/indata

Create GRASS location using SPEARFISH data to be able create new locations

  $ cd ~/grass
  $ tar zxf spearfish_grass60data-0.3.tar.gz

Start GRASS

  $ grass -text spearfish60/PERMANENT

Obtaining Data

We assume that one wants to create UK map. Following steps can be easily applied to other countries' data.

Country related GIS data can be obtained from Digital Chart of the World.

First create country related input directory

  $ mkdir ~/grass/indata/uk

Let's download UK data

  • go to Digital Chart of the World
  • click Europe link
  • choose United Kingdom in select box on the right and click Continue
  • page _Digital Chart of the World Layer Interface for United Kingdom_ will be displayed
  • click Download Data button
  • another page will be shown, mark checkboxes
    • Populated Places (Polygon)
    • Roads (Line)
    • Rail Roads (Line)
  • click Continue
  • on new page click Compute Data
  • on new page you will be able to obtain set of data (<NUMBER> is part of filename with data exported by DCW)
  <NUMBER>.tar.Z
  • do not hesistate to download data into ~/grass/indata/uk directory

Downloading Names of Cities

NGA GEOnet Names Server provides free GIS data containing positions of cities and their names.

Data can be downloaded from FTP server

  ftp://ftp.nga.mil/pub/gns_data/

Direct link to UK GNS data

  ftp://ftp.nga.mil/pub/gns_data/uk.zip

Download UK data into ~/grass/indata/uk directory.

Importing Data

Importing data into GRASS is two fold step

  • create new location with one piece of data
  • import remaining data

Creating New Location

One can create new location using another location. We will use SPEARFISH location to create UK location.

Start GRASS

  $ cd ~/grass
  $ grass62 -text spearfish60/PERMANENT (you need grass 6.2.x for this to work)

Enter UK input data directory and unpack downloaded data from DCW

  $ cd indata/uk
  $ tar zxf <NUMBER>.tar.Z

You will have several files

ponet.e00
country borders
pppoly.e00
populated places
rdline.e00
road network
rrline.e00
rail road network

We will create UK GRASS location using country borders. In SPEARFISH GRASS session use following commands to create location uk and layer borders

  $ cd ~/grass
  $ v.in.ogr dsn=indata/uk/ponet.e00 layer=ARC output=borders location=uk

New location is created. Exit SPEARFISH GRASS session and start GRASS UK session

  $ cd ~/grass
  $ grass62 -text uk/PERMANENT

You can display UK borders

  $ g.region vect=borders    # set region to display
  $ d.mon x0                 # create GRASS monitor
  $ d.vect map=borders       # display borders

Importing Rest of the Data

Having GRASS UK location we can import rest of the data (population places, road and rail networks)

  $ cd ~/grass
  $ grass -text uk/PERMANENT
  $ v.in.ogr dsn=indata/uk/pppoly.e00 layer=ARC output=pcities
  $ v.in.ogr dsn=indata/uk/rdline.e00 layer=ARC output=roads
  $ v.in.ogr dsn=indata/uk/rrline.e00 layer=ARC output=rails

Display data

  $ d.mon x0
  $ g.region vect=borders
  $ d.vect map=borders color=black width=1.2
  $ d.vect map=roads   color=grey           
  $ d.vect map=pcities color=brown

or save it to PNG file uk.png

  $ GRASS_WIDTH=1024 GRASS_HEIGHT=1024 GRASS_PNGFILE=uk.png d.mon start=PNG
  $ d.mon select=PNG
  $ d.vect map=borders color=black width=1.2                             
  $ d.vect map=roads   color=grey                                        
  $ d.vect map=pcities color=brown                                       
  $ d.mon stop=PNG

Import Data from GNS

Downloaded GNS data can be imported into GRASS using v.in.gns script.

Uncompress GNS data

   $ cd ~/grass/indata/uk
   $ unzip uk.zip

Start GRASS UK session

   $ cd ~/grass
   $ grass62 -text uk/PERMANENT

Import data

   $ v.in.gns file=indata/uk/uk.txt vect=cities

Processing Data

GNS data contains information about large amount of cities. Usually it is uncovinient to see all this data on a map. GRASS allows us to create new vector layers of cities.

Example below will show how to create new vector layer from GNS data for major country cities.

Start GRASS session

   $ cd ~/grass
   $ grass62 -text uk/PERMANENT

Extract data from cities vector layer to mcities vector layer

   $ v.extract --o output=mcities input=cities where="(DSG='PPLA' or DSG='PPLC') and NT='N'"

Above selects those names of cities, which

  • name type is 'N'
  • Feature Designation Code (DSG) is PPLA or PPLC

Create labels using FULLNAME column

   $ v.label labels=mcities map=mcities column=FULLNAME size=0.1

Display map

   $ d.mon x0
   $ d.vect map=borders color=black width=1.2
   $ d.vect map=mcities icon=basic/circle color=black fcolor=red size=4
   $ d.labels labels=mcities

Other columns can be used to filter data or create labels. GNS columns are described at GNS Help page.