6. Converting Map Projections of ShapeFiles

The CONVERT_SHAPE mode of the allocator program can be used to convert a shapefile in one map projection to another map projection. Scripts called convert_shape are provided to assist with this operation. The scripts take two arguments: the directory and file name of the input file and the directory and file name of the output file (file names are without extensions). January 2008 version and subsequent versions ofthe Spatial Allocator support geographic transformation of the datum. If the geographic datum or ellipsoid of input projection is different from that of output projection, you should specify the datum information accordingly. Also note that the old LATLON map projection and SPHERE ellipsoid are no longer supported.

The scripts automatically set the INPUT_FILE_NAME and OUTPUT_FILE_NAME variables to the command line arguments provided. The OUTPUT_FILE_TYPE and INPUT_FILE_TYPE variables are set and should not need to be changed. Before running the scripts, set the values of the INPUT_FILE_MAP_PRJN, INPUT_FILE_ELLIPSOID, OUTPUT_FILE_MAP_PRJN, and OUTPUT_FILE_ELLIPSOID to the projections desired for the input and output files. An example conversion script is shown below.

setenv EXE $SA_HOME/bin/allocator.exe

if ($#argv < 2) then
  echo "Usage: convert_input_shape.csh input_shapefile output_shapefile (no file extensions)"
  exit 2
endif

setenv MIMS_PROCESSING CONVERT_SHAPE

setenv OUTPUT_FILE_TYPE    RegularGrid     # Type of grid
setenv INPUT_FILE_TYPE   ShapeFile         # Type of input data file
setenv INPUT_FILE_NAME    $argv[1]       # shape file name - no extension
setenv OUTPUT_FILE_NAME   $argv[2]    # shape file name - no extension

#set input projection for nashville grid to convert outputs to ll
#setenv INPUT_FILE_MAP_PRJN "+proj=lcc,+lat_1=30,+lat_2=60,+lat_0=40,+lon_0=-100"

#set input projection to EPA Lambert to convert surrogate input files to ll
setenv INPUT_FILE_MAP_PRJN "+proj=lcc,+lat_1=33,+lat_2=45,+lat_0=40,+lon_0=-97"
setenv INPUT_FILE_ELLIPSOID  "+a=6370997.00,+b=6370997.00"
setenv OUTPUT_FILE_MAP_PRJN   "+proj=latlong"       # map projection for data poly file
setenv OUTPUT_FILE_ELLIPSOID  "+a=6370997.00,+b=6370997.00"

# ssusuage is good on the SGI for mem & CPU usage
#setenv TIME ssusage
setenv TIME time

echo "Converting from $INPUT_FILE_MAP_PRJN to $OUTPUT_FILE_MAP_PRJN"
echo "Input file = $INPUT_FILE_NAME"
echo "Output file = $OUTPUT_FILE_NAME"
$TIME $EXE


To Section 7: Other Spatial Functions