0

I want to project many raster files in a folder (but they appear in the content of my ArcGIS project). Here is the screenshot.

enter image description here

These raster files have an unknown coordinate system. When I try to project them manually, the input and output coordinate system is shown below. And I have successfully project several raster files manually.

enter image description here

As you can see, the input and output coordinate system is the same "GCS_WGS_1984". I can manually project these raster files but want to find how to accomplish this using python. Also, after projecting, how to make sure they will appear in my gdb project for future use.

I tried to use the following code but it did not work.

import arcpy
arcpy.env.workspace = r"D:\STAR\info_data_test"
#this is the folder where raster files are
arcpy.env.overwriteOutput = True #overwrite the exsiting files

rasterfiles = list(set(arcpy.ListDatasets("b*","Raster")))
#list all the raster files inside the folder with name starting "b"

base = "D:/STAR/assignment/assignment7/Zhenyu_Assign7_GISpro/Zhenyu_Assign7_GISpro.gdb/b90w90r65s400Pro"
#using the exsiting projected raster file as base 
out_coor_system = arcpy.Describe(base).spatialReference
#get the coordinate system of this base raster file

for raster in rasterfiles:
    outraster = raster + "Pro"
    arcpy.ProjectRaster_management(raster,outraster,base)

I do not know how to project these raster files and then put them into my gdb project for future use.

4
  • 1
    Why are you projecting to the same geographic coordinate system (i.e. GCS_WGS_84 to GCS_WGS_84)?
    – Aaron
    Commented Apr 12, 2019 at 3:12
  • 1
    If the coordinate system is unknown you should be using Define Projection, not Project Raster. How do you know it is unknown, have you right-clicked the layer - Properties - Source - Spatial reference?
    – Bera
    Commented Apr 12, 2019 at 5:09
  • Thanks for replying. I got the data from other researchers and they told me the coordinate system is GCS_WGS_1984. But these rasters could not match with layers with GCS_WGS1984. Hence, I try to project them to GCS_WGS1984 and find the projected ones can match with other layers with GCS_WGS1984. So, in order to do future work, I decided to project all rasters to this coordinate system. @BERA
    – Zhenyu
    Commented Apr 12, 2019 at 13:38
  • @Aaron, thanks for replying too. As the comments I posted, the coordinate system of rasters can not match with other layers with same coordinate system. However, after projecting, projected ones can match with layers with GCS_WGS_1984. That is why I want to project to the same coordinate system.
    – Zhenyu
    Commented Apr 12, 2019 at 13:42

1 Answer 1

0

I do not know how to project many raster files but I figured a method in ArcGIS Pro.

First, find the tool "Project Raster" in the Geoprocessing and then right-click this tool. You will find "Batch" when you right-click the tool. Choose this "Batch" and then you will find the Batch Project Raster, you can choose many raster files in the "Input Raster" and change the output name in the "Name".

Normally, ArcGIS Pro provides batch for geoprocessing tools. If you want to deal with many files, it will be easy to use this method. The following screenshot indicates the detailed information for this method.

enter image description here

Your Answer

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

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