Wednesday, 5 October 2016

coordinate system - Looping Projection in ArcGIS ModelBuilder?


I've got a global DEM raster dataset in WGS84 and need to project this to all WGS84 UTM Zones. So after that I should have 120 raster, one in each Zone.


Is there a possibility to automate this process with the ArcMap ModelBuilder? I tried the "for" iterator, but I can't choose the epsg as iterating value.




Then I need to run the flow length tool on all those rasters and then reproject the resulting 120 flow length rasters again into WGS84.


Do you have any idea for an efficient way to create a ModelBuilder path for that?



Answer



I suggest you use Python for this. The code can be executed in the Python window of ArcGIS.



import arcpy, os

dem = r'C:\folder\dem.tif' #Change to match your DEM. Can also be a raster in a database
out_folder = r'C:\outfolder' #And this. If it is a database, remove .tif below

#List all UTM epsgs:
epsgs = range(32601,32661) + range(32701,32761)

#Project raster for each:
for epsg in epsgs:

print 'Reprojecting to epsg: ',epsg
arcpy.ProjectRaster_management(in_raster=dem, out_raster=os.path.join(out_folder,'Reprojected_epsg_{0}.tif'.format(epsg)),
out_coor_system=arcpy.SpatialReference(epsg))

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...