Lab 1 and 2, Introduction to Geographic Modeling – GIS data formats, import and export

 

The following exercises are designed to give the student:

 

1)      an understanding of how raster maps are created from vector data,

2)      how to grid vector data for modeling in ArcMap,

3)      the opportunity to review some raster and vector operations in ESRI’s ArcMap

4)      familiarity with the process of exporting and importing data between various GIS programs and formats

5)      the ability to convert data from one format to another, or one GIS program to another, using FORTRAN (a handy tool when the export/import functions fail).

 

Data Required: Download here

 

 

1.      One ArcInfo coverage in export format called p30hya.e00, a map of hydrology (rivers, lakes), and

2.      a USGS digital elevation model called p30elu.dem for the Syracuse East quadrangle

3.      An aerial photo

 

Steps we’ll follow today:

 

  1. Hand digitize aerial photo as follows using notepad:

 

0  0  0  0  1  1  1  0  0  0

0  0  1  1  1  1  1  1  0  0 etc……

 

2.      Save with a file name of landuse.sqr.

3.      Write a FORTRAN program (we’ll do this all together and call it SQR2ASC.f90) to convert this square file to an ASCII grid file format, which we’ll name landuse.asc.  See the format of an .asc format file below.  Note that it has a header.

4.      Start up ArcGIS à ArcCatalog à

5.      Import landuse.asc into ArcMap using the Arc Toolbox à Conversion Tools à to Raster and call it Landuse

6.      Display it (VIEW menu, Add Theme), view its map coordinates (just by moving the cursor across the map and looking in the upper right corner coordinate display box).  What units are they?  Why?

7.      Open p30elu.dem using Wordpad.  Describe the format of the data as best you can.

8.      Import into ArcMap the p30elu.dem using the Arc Toolbox à Conversion Tools à to Raster à DEM to Raster,  and call it SYRE_DEM.  Display it.  Why can’t you display it in the same window with the LandUse file?

9.      What is the file format of the SYRE_DEM after importing to ARCGIS?

10.        Import the export file p30hya.e00 and name it SYRE_Hyd. 

 

11.  What is the file structure of SYRE_Hyd?  What kind of map is it called at this point?  How does it differ from SYRE_Dem?

12.  Display SYRE_hyd in the same window as SYRE_Dem.

13.  Grid the hydrology map (SYRE_Hyd) to match the origins, and number of rows and columns of the DEM, and name it SYREhyd_grid.

14.  Convert SYRE_HYD to a shape file of the same name (we’ll import this next week into IDRISI32).  Use the Arc Toolbox à Conversion Tools à To Shapefile à Feature Class to Shapefile.

15.  What is the SYRE_Hyd shape file structure? What is its grid file structure (SYREhyd_grid)?

16.  Export both the SYREhyd_grid  and SYRE_dem to an ASCII grid format and use the names SYRE_Hyd.asc and SYRE_dem.asc.

 

Homework:

  1. Write a program called ‘ASC2RST.f90’ to convert both p30hyd_grid and p30dem_grid from ASCII grid format to an IDRISI raster file format.  Name the new maps ‘SyrE_hyd.rst’ and ‘SyrE_dem.rst.’  In order to display these maps in IDRISI you will need to create an accompanying document file.  You can do this in IDRISI under FILE -> Metadata.  To find out the projection consult their metadata files at:

http://cugir.mannlib.cornell.edu/transform?xml=36dea.xml

 

Next week:   To make your life easier you will write a subroutine to create the IDRISI document (.rdc) file.  Name this file ‘SyrE_hyd.rdc’ or ‘SyrE_dem.rdc’ to accompany either your dem or hydrography file.  An example of the file format is provided below.  Use the header of the exported SYRE_Hyd.asc or SYRE_dem.asc file to provide information that is required in the IDRISI document file.  The test of your success will be whether or not you can display the map  in IDRISI.  We will do that in next week’s lab. 

 

Products to turn in after two weeks:

 

1.      Short description of what you did and why

2.      Answers to questions above

3.      Your working code to convert ‘SYREhyd_grid.asc’ to ‘SyrE_hyd.rst

              to convert ‘SYRE_.asc  to ‘SyrE_dem.rst 

        to create the .rdc (IDRISI document ) file for both maps

4.  Hard copy of converted maps (in IDRISI)

 

Pseudo Code to follow:

 

Declare Variables, make landuse array allocatable (see below*)

Open files, both input and output

For the input ascii grid file (use a ‘DO loop’)

Read in header information  (see format below)

Read in Data                         (see format below)

     For the output IDRISI file (use a ‘DO loop’)

Write out IDRISI raster file (.rst)         (see format below)

Write out IDRISI document file (.rdc) (see format below) EXTRA CREDIT Subroutine

     Deallocate arrays

     Close files

 

Useful FORTRAN tool:  How to allocate and deallocate memory space, i.e. to make arrays dynamic, or useful when you don’t know how many rows and columns a file has and you can’t open it to see because it’s too big.

 

 

INTEGER, ALLOCATABLE, DIMENSION (:,:) :: LU

Or

INTEGER, ALLOCATABLE:: LU(:,:)

Read (1,99) header, Nrows

Read (1,99) header, Ncols

ALLOCATE (LU(Nrows,Ncols))

99 FORMAT (A14,I5)

 

 

The IDRISI ASCII grid file format:

 

Format requirements of an IDRISI (.rst) file

 

No header, row major, one grid cell (Z) value per line, origin is upper left corner of map.  Internally IDRISI numbers rows and columns starting with 0,0. In  IDRISI32 you must convert files in ASCII format to binary format before displaying.

 

Example of an IDRISI raster file data format:

12

13

5

10

6

10

 

Information on how the data should appear in the SyrE_dem.rdc (IDRISI document file).  This example is for the South Onondaga Quad:

 

file format : IDRISI Raster A.1

file title  : SOUTH ONONDAGA, NY                     

data type   : integer

file type   : ascii

columns     : 1040

rows        : 1403

ref. system : us27tm18

ref. units  : m

unit dist.  : 1.0000000

min. X      : 397899.7812500

max. X      : 408305.0937500

min. Y      : 4747328.0000000

max. Y      : 4761363.0000000

pos'n error : unknown

resolution  : unknown

min. value  : 0.0000000

max. value  : 495.7000122

display min : 0.0000000

display max : 495.7000122

value units : m

value error : unknown

flag value  : none

flag def'n  : none

legend cats : 0

lineage     : This file was created by DEMIDRIS with the command line:

lineage     : d:\gis_data\onondaga\q29elu.dem*d:\gis_data\onondaga\s_onondem.rst

 

 

 

A GEOPLOT square file (.SQR) was designed by Charles Hall to be used by programmers as an intuitive way to examine mapped data using an ASCII text editor such as Pedit.  A true example cannot be shown here as this program (MS Word) would wrap the data but it looks something like this:

 

 2  2  4  3  3  2  2  1  1  1                        where 1, 2, and 3 represent land uses

 2  2  2  4  3  2  2  2  1  1                        and 4 represents a road or a stream

 2  2  2  2  4  2  2  1  1  1

 2  2  2  2  2  4  1  1  1  1

 

Using a text editor such as PEdit allows you to view the data just as it appears in the map, i.e. in full rows and columns.

 

The file Format requirements of a GEOPLOT (.sqr) file:

 

No header, row major, one row of Z values at a time, columns are space delimited.  Origin is upper left corner of map.  

 

The ASCII raster (grid) (.ASC)  file format is a simple format that can be used to transfer raster data between various GIS software packages such as ERDAS, ARC/INFO GRID in ARCGIS9, and ARCVIEW Spatial and 3-D ANALYST.  It is basically a few lines of header information followed by the cell values.  The data can have any format, but the common protocol followed is to write out the data so that it can all be viewed with a text editor within the column limits of a computer screen.  Use PEdit or notepad to determine what that number of spaces is.  The header data includes the following keywords and values:

 

 ncols                           - number of columns in the data set.

 nrows                         - number of rows in the data set.

 xllcenter or xllcorner - x-coordinate of the center or lower-left corner of the lower-left cell.

 yllcenter or yllcorner - y-coordinate of the center or lower-left corner of the lower-left cell.

 cellsize                        - cell size for the data set.

 nodata_value            - value in the file assigned to cells whose value is unknown. This keyword and value is optional. The nodata_value defaults to -9999.  –9999, and –32768 for greater than 8 bit data, are commonly used.

 

For example,

ncols         2543

nrows         2333

xllcorner     723463.6875

yllcorner     7178191.5

cellsize      30

NODATA_value  -9999

-9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999

-9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999

-9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999 -9999

 

The first row of data is at the top of the data set, moving from left to right. Cell values should be delimited by spaces. Tabs must not be used in ASCII. No carriage returns are necessary at the end of each row in the data set. The number of columns in the header is used to determine when a new row begins. The number of cell values must be equal to the number of rows times the number of columns.