I have over 100 shape files that don't have .prj file and thus when I bring them into ArcMap 10 they show the coordinate system as unknown. I know all of the shape files coordinate system is GCS WGS 1984. I also know I can use the Define Projection GP tool to individually assign the coordinate system to each file but that will take forever.

I was hoping there was a GP tool to batch define these but I don't see one. Next I was thinking maybe I could use python to do this so I looked in the help menu and found a script but it gives me an error.

Here is the python code I tried (this is for a single shp file so I would still have the pain of typing the name for each file:

import arcpy
infc = r"C:\Documents and Settings\User\My Documents\ArcGIS\shpfiles\Site_2.shp"
prjfile = r"<install directory>\Coordinate Systems\Geographic Coordinate Systems\World\WGS 1984.prj"
arcpy.DefineProjection_management(infc, prjfile)
  • But If I want to define projection for multi raster files, what can I do?
    – user22830
    Oct 11, 2013 at 4:24

6 Answers 6


I think you guys are overthinking this one...

  1. Right-click on the "Define Projection" tool in toolbox,
  2. select "Batch",
  3. drag-and-drop your layers into the "Input Dataset" column,
  4. right-click in the first "Coordinate System" box to fill out the correct projection,
  5. then right-click on the projection you just selected and choose "Fill" which will fill out all of the rest of the projections for you.
  6. Hit "OK" and you are done.

alt text

  • Does that actually generate the Shapefile .PRJ helper file in the OS folder, or just annotate a layer attribute? And you'd have to launch ArcGIS as well. The Python script Jay put up will do its work completely outside ArcGIS, with certain results--good for non-ESRI needs. Jan 7, 2011 at 23:26
  • Yes, the "Define Projection" tool writes a PRJ file for all shapefiles that are processed through it. While I agree the python script Jay posted will probably work great, scripting is often outside the skill set of an average GIS specialist, whereas the push-button "Define Projection" utility is not. Jan 7, 2011 at 23:52
  • 1
    Thanks Ryan, I hand no idea that you could right-click on GP tool to get more options. That is a nice trick and was just what I was looking for. Much appreciated.
    – wilbev
    Jan 8, 2011 at 1:47

If they are in the same directory, something like this would work (just replace your paths, maybe add in some exception handling):

import os, shutil

wgs84prjpath='c:/Program Files/ArcGIS/Desktop10.0/Coordinate Systems/Geographic Coordinate Systems/World/WGS 1984.prj'

def definewgs84(shpfilepath):
    tgtpath = os.path.splitext(shpfilepath)[0] + '.prj'


shpfileslist = [file for file in os.listdir(yourshapefiledirectory) if file.lower().endswith(extension)]

for filename in shpfileslist:
  • I tried this route because I want to learn to use to Python more but I was not successful. It is erroring out on the 'os' name. I pasted in the error message below. Any ideas what may be wrong?
    – wilbev
    Jan 8, 2011 at 1:49
  • Sorry that got added before I pasted in the error, here it is: Runtime error <type 'exceptions.NameError'>: name 'os' is not defined
    – wilbev
    Jan 8, 2011 at 1:50
  • oops...the imports would help!: import os, shutil (see the updated the answer). docs.python.org/tutorial/stdlib.html should you there. Jan 8, 2011 at 1:52

Just make copies of the .prj and rename. So, e.g., if you have 3 shapefiles:

  • one.shp,
  • two.shp,
  • three.shp.

Define the projection for one.shp and you will have one.prj in the directory. Copy one.prj to the directory of two.shp and rename to two.prj, repeat for all shapefiles. The .prj is just a text file. As long as there is a .prj in the same directory as a .shp and with the same name, the software will pick it up. Automate with whatever tools you are familiar with for copying and renaming files.



Probably the easiest method would be. Bring them all in and assign the correct crs to the document. They would be "unprojected" but sitting in the right place. Then just export (multiple) to a new location.

I do see a GP tool for batch projection.

batch proj

It may not be exposed in arcpy. ??

I think I would create a pgdb, (File, personal or even sde) and then create a fds (feature data set).

Assign the appropriate crs to that fds.

Import the shape files (multiple). [all fc in a fds inherit the crs of the fds].

Then you can export to shape file (multiple).

This would be in lieu of batch projection, and I'm sure could be scripted.

  • Although this method does work, it takes much longer than what Ryan Dalton suggested. The import of over 100 shape files into a feature class is very slow.
    – wilbev
    Jan 8, 2011 at 1:51

how about a simple shell script and ogr2ogr? See http://www.gdal.org/ogr2ogr.html for the exact syntax.


Here's what I use...it will only define the projection for raster files which don't have a projection. Hope it helps. It also creates a list of the files without projection for Quality Assurance purposes.

For your vectors it just needs a slight mod - FileList=arcpy.ListFeatureClasses()

# Defines projection for all rasters with undefined projection
# CAUTION - make sure you know that the projection you are defining is the correct one
# for all files in the current directory.

#Licence: Creative Commons
#Created by: George Corea; georgec@atgis.com.au, coreagc@gmail.com

import arcpy, glob, os, sys, arcgisscripting
from arcpy import env, mapping
path = os.getcwd()
env.workspace = path
env.overwriteOutput = True

print 'Reading files from ' + path

FileList= arcpy.ListRasters()
for File in FileList:
    desc = arcpy.Describe(File)
    SR = desc.spatialReference
    if SR.name == "Unknown":
        print "Projection of " + str(File) + " is " + SR.name + " so defining projection."
        f = open('NoProjection.txt', 'a')
        arcpy.DefineProjection_management(File, prjFile) 
        print File + " is projected " + str(SR.name)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.