You are on page 1of 2

NRM638 Spring 2013 Python Scripting Due By Friday 1-Feb-2013 5pm

Python scripting

If you are on the UAF campus, I will help you during class time Monday 3:30 pm ONEILL 359. If your off-campus, you can email me any scripting problems as they arise and I will try to email you back the same day. The Python os module allows you to perform operating system tasks such as making directories (folders), renaming files, and listing files. The os.mkdir() function allows you to make a directory using your python script. Email me at dlverbyla@alaska.edu your four python script .py files. I need them by Friday 1-Feb-2013 5pm, so I can grade all the student scripts on Saturday. 1) You will be working with SNAP climate data as monthly mean temperature and monthly total precipitation rasters. Write a python script named months.py that creates a folder for each month of the yearsubdirectories Jan, Feb, MarDec

2) Write a python script named years.py that creates folders from 2000 to 2013.

3) Write a python scripted named MonthsYear.py that creates month folders inside each of your existing subdirectories 2000, 2001, 2013.

NRM638 Spring 2013

Python scripting

4) Write a script named check_shapefiles.py that will check that of all shapefiles in a folder have a defined coordinate system. A *.shp file would have a companion *.prj file if it has a defined coordinate system Download and unzip the file Shapefiles.exe from http://nrm.salrm.uaf.edu/~dverbyla/nrm638/data For example, the script discovers the following :

As an example,

You can do this by using the glob module to create a list of files *.shp, then stripping off the shp extension, and searching for the companion .prj file. For example, for one shapefile line2.shp

You might also like