Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a new question and I hope somebody can help me with this.

I have got a shapefile which shows the extent of every raster I have. Some of these rasters are georeferenced but some not. Now I would like to add a x to the attribute table where the raster is georeferenced. I know that there must be a way with python GetRasterProperties but I'm not sure how to write the script. Maybe someone of you did the same and can give me some help.

I have to do this with ArcGIS 10 and it must be easy to update when new rasters are georeferenced.

share|improve this question
Do the rasters that are not georeferenced lack any sort of spatial reference altogether? As in they are just images without any spatial reference yet? If so, you can use arpcy.Describe to check for a spatial reference, and if it returns null (or whatever the missing spatial reference return is), add an 'X' to a field. – egdetti Jan 7 '13 at 16:54

I'm assuming you are georeferencing scanned maps or the like that do not have an associated coordinate system. The attached script creates a table and adds "x" to the row which corresponds to the undefined raster. You should have no problem retrofitting the script to perform the same action with your shapefile. The attached screenshot shows how the script looped through a folder, recorded the raster name and determined whether or not there was an assigned coordinate system.

enter image description here

import arcpy
from arcpy import env

arcpy.env.overwriteOutput = 1

# Set the workspace
env.workspace = r'C:\temp'
Dir = env.workspace

# Create a table and add fields
TableName = "TempTable.dbf"
arcpy.CreateTable_management(Dir, TableName)
arcpy.AddField_management(Dir + "\\" + TableName, "RasterName", "TEXT")
arcpy.AddField_management(Dir + "\\" + TableName, "cs", "TEXT")

# Get the list of raster files
rasters = arcpy.ListRasters()

# Loop through the files and perform the processing
for ras in rasters:

    # Create insert cursor and add values to the table
    rows = arcpy.InsertCursor(Dir + "\\" + TableName) 
    row = rows.newRow()
    row.RasterName = str(ras)

    # Determine if the input has a defined coordinate system
    dsc = arcpy.Describe(ras)         

    if dsc.spatialReference.Name == "Unknown":

        row.cs = "x"     # Adds "x" to the row which corresponds to the undefined raster


        print str(ras) + " has a coordinate system"

    del rows
    del row
share|improve this answer
More or less that is what I'm looking for. One problem is that my rasters are in subfolders so I have to loop through. But I will try it. Thanks! – GIS Friend Jan 8 '13 at 11:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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