2

I have a raster which I want to reproject from GCS_WGS_1984 to GCS_NorthAmerican_1983. I am using the following code:

    try:  
        spatial_ref = arcpy.CreateSpatialReference_management("GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]];-400 -400 1000000000;-100000 10000;-100000 10000;8.98315284119521E-09;0.001;0.001;IsHighPrecision", "", "", "", "", "", "0")
    except:
        print arcpy.GetMessages()

    try:
        arcpy.Project_management(o_dir+int_ras,o_dir+geo_int_ras,spatial_ref)
    except:
        print arcpy.GetMessages()

It gives the error: ERROR 000732: Input Dataset or Feature Class: Dataset does not exist or not supporte

However, the input datasets most defn exist. Is there some issue with how I am reprojecting?

  • 2
    how do o_dir and int_ras look like ? make sure you have "\\" whan you concatenate your paths. – radouxju Feb 20 '14 at 9:09
  • 1
    As @radouxju suggests, I think these variables may not be set to what you think so don't be afaraid to use print statements to double-check what they are just before you use them in a tool that is throwing an error. – PolyGeo Feb 20 '14 at 9:36
  • Thanks guys, but my path is ok. '\\' are in place. However, the error persists. Interestingly, if I bypass the proejection, the next step in the geoprocessing happens just fine i.e. it has no issues with missing datasets. – user1186 Feb 20 '14 at 15:55
  • 3
    Use ProjectRaster, not Project. And I probably wouldn't bother if you're just going WGS84 to NAD83 (lat/lon) if the cell size is more than a meter. Just redefine it using DefineProjection. – mkennedy Feb 20 '14 at 17:22
6

Might as well makes this an answer.

The Project method/tool works with vector data only. To reproject a raster, you need to use the Project Raster tool. That is, the ProjectRaster_management method. The help topic for ArcGIS for Desktop 10.2 is here. Here's the arcpy sample from the help:

import arcpy
from arcpy import env
arcpy.ProjectRaster_management("c:/data/image.tif", "c:/output/reproject.tif",\
                               "World_Mercator.prj", "BILINEAR", "5",\
                               "NAD_1983_To_WGS_1984_5", "#", "#")

It takes a coordinate system, not a spatial reference, and has different parameters (like resampling type and cell size).

On a separate note, is the input raster using WGS 1984, latitude-longitude, or is it actually in a projected coordinate system that's based on WGS 1984? If the former, and the cell size is more than a meter, I wouldn't bother reprojecting the raster but instead use the Define Projection tool and simply change the coordinate system to NAD 1983.

NAD 1983 and WGS 1984 differ by 1-2 meters only. If your raster's cell size is about that or larger, it's not going to make a difference if you project it and will just cause an unnecessary resampling.

  • Thanks mkennedy! The input raster is WGS 1984 (using lat lon) and has a resolution of 0.25 degrees. I defn want to avoid any resampling. – user1186 Feb 20 '14 at 19:00

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.