I currently have a raster that has a Geographic Coordinate System but no Projected Coordinate System, which I need to have.
I am using Python and trying to use ArcPy's "ProjectRaster_Management" feature.
So first I have this:
input_directory = 'C:\\Users\\lavendarfire\\files'
arcpy.env.workspace = input_directory
rasters = arcpy.ListRasters("*.hdf")
raster = rasters[0] (just testing one raster)
output_file_name = raster[:-4] + '_test' + ".tif"
input_file_name = "C:\\Users\\lavendarfire\\files\\input.hdf"
and then this:
arcpy.ProjectRaster_management(input_file_name, output_file_name, "PROJCS['World_Mollweide',GEOGCS['GCS_WGS_1984',DATUM['D_WGS_1984',SPHEROID['WGS_1984',6378137.0,298.257223563]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['World_Mollweide'],PARAMETER['false_easting',0],PARAMETER['false_northing',0],PARAMETER['central_meridian',0],UNIT['Meter',1.0]]")
This gives me an error.
C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py in ProjectRaster(in_raster, out_raster, out_coor_system, resampling_type, cell_size, geographic_transform, Registration_Point, in_coor_system, vertical)
11441 return retval
11442 except Exception as e:
> 11443 raise e
11444
11445 @gptooldoc('RegisterRaster_management', None)
C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py in ProjectRaster(in_raster, out_raster, out_coor_system, resampling_type, cell_size, geographic_transform, Registration_Point, in_coor_system, vertical)
11438 from arcpy.arcobjects.arcobjectconversion import convertArcObjectToPythonObject
11439 try:
> 11440 retval = convertArcObjectToPythonObject(gp.ProjectRaster_management(*gp_fixargs((in_raster, out_raster, out_coor_system, resampling_type, cell_size, geographic_transform, Registration_Point, in_coor_system, vertical), True)))
11441 return retval
11442 except Exception as e:
C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py in <lambda>(*args)
509 val = getattr(self._gp, attr)
510 if callable(val):
--> 511 return lambda *args: val(*gp_fixargs(args, True))
512 else:
513 return convertArcObjectToPythonObject(val)
ExecuteError: ERROR 000622: Failed to execute (Project Raster). Parameters are not valid.
ERROR 000628: Cannot set input into parameter out_coor_system.
What am I doing wrong while writing World_Mollweide?
The Projected Coordinate systems PDF from ArcGIS states that the name for what I want can be referred to as "World_Mollweide" 54009 https://desktop.arcgis.com/en/arcmap/latest/map/projections/pdf/projected_coordinate_systems.pdf
World
and afterMollweide
are not escaped. This is a place for Python's triple-quote technique."
) characters are required in that format. The best way to script things the first time is to run the command from the UI, then "Copy as Python snippet" from the Geoprocessing Results page for that command.