0

I want to project HDF files (MODIS images) to another coordinate system using ArcPy. The following is the code I wrote:

input_ras="N:\\mod16a2\\MOD16A2.A2001001.h24v05.006.2017068142418.hdf"
out_ras= "\test.tif"
# the coordinate system which is required
out_co="G:\\Rathore\\vic_auto7\\shape_proj.prj"
arcpy.ProjectRaster_management(in_raster=input_raster,out_raster=out_ras,out_coor_system=out_co)

This script produces the following error:

ExecuteError Traceback (most recent call last)
<ipython-input-95-0d17576ef2fe> in <module>()
 arcpy.ProjectRaster_management(in_raster=input_ras,out_raster="out_ras,out_coor_system=out_co)
C:\Program Files (x86)\ArcGIS\Desktop10.5\ArcPy\arcpy\management.py in ProjectRaster(in_raster, out_raster, out_coor_system, resampling_type, cell_size, geographic_transform, Registration_Point, in_coor_system)
 9700 return retval
 9701 except Exception as e:
-> 9702 raise e
 9703 
 9704 @gptooldoc('RegisterRaster_management', None)
ExecuteError: Failed to execute. Parameters are not valid.
Undefined coordinate system for input dataset.
Failed to execute (ProjectRaster).

I checked the projection of input file and it is:

"PROJCS['Unknown_datum_based_upon_the_custom_spheroid_Sinusoidal',GEOGCS['GCS_Unknown_datum_based_upon_the_custom_spheroid',DATUM['D_Not_specified_based_on_custom_spheroid',SPHEROID['Custom_spheroid',6371007.181,0.0]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Sinusoidal'],PARAMETER['false_easting',0.0],PARAMETER['false_northing',0.0],PARAMETER['central_meridian',0.0],UNIT['Meter',1.0]]")
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jul 31, 2019 at 4:37
2
  • Are you running your code from IDLE or from somewhere else? Commented Mar 18, 2021 at 0:31
  • Does your code work if you copy N:\\mod16a2\\MOD16A2.A2001001.h24v05.006.2017068142418.hdf to be C:\\temp\\test.hdf and use that path instead of the one with multiple dots in it? Commented Apr 4, 2021 at 22:37

1 Answer 1

2

The way to resolve this is to put in the full projection of the coordinate system for input dataset as an argument to ProjectRaster_management:

arcpy.ProjectRaster_management (ifpn, ofpn, "4326", "NEAREST", "#", "#", "#", "PROJCS['Unknown_datum_based_upon_the_custom_spheroid_Sinusoidal',GEOGCS['GCS_Unknown_datum_based_upon_the_custom_spheroid',DATUM['D_Not_specified_based_on_custom_spheroid',SPHEROID['Custom_spheroid',6371007.181,0.0]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Sinusoidal'],PARAMETER['false_easting',0.0],PARAMETER['false_northing',0.0],PARAMETER['central_meridian',0.0],UNIT['Meter',1.0]]")

ifpn and ofpn are my input and output rasters respectively. If these are already assigned your variables (as you did with input_ras and out_ras), you don't need to reassign them within the function.

PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
answered Feb 9, 2020 at 11:57

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.