rich_white

Setting projection in a python script - 9.3

Discussion created by rich_white on Jul 20, 2011
Latest reply on Jul 20, 2011 by curtvprice
Hi,

I have a python script that batch converts ascii files to other raster types.

How do I hard code in a projection, in this case wgs84, so it sets the projection after each ascii file is converted. Below is the part of the code that does the conversion;

# Loop through the list of input Rasters and convert/copy each to the output geodatabase or folder
    for inRaster in inRasters_list:
        # Get filename correct
        rasterBaseWithExt = os.path.split(inRaster)[1]
        rasterBase = string.split(rasterBaseWithExt,".")[0]
        ourRasterBase = rasterBase
        rasterBase = "\\" + rasterBase
        outRaster = outWorkspace + rasterBase + ext
       
        try:
           
            # Copy/Convert the inRaster to the outRaster
            gp.ASCIIToRaster_conversion(inRaster, outRaster, format)
##            gp.ASCIIToRaster_conversion(inRaster, outRaster, "FLOAT")
            # If the Copy/Convert was successfull add a message stating this
            gp.AddMessage(msgSuccess + "%s To %s \n\n" % (rasterBaseWithExt, ourRasterBase))

Thanks for any help.

Regards,

R.

Outcomes