Batch Project Raster Tool
#1
Posted 27 January 2010 - 10:54 PM
I bascially have 300+ raster that needs to be reprojected, it'll be awesome if there is a way to do automatically rather than one at a time.
I've tried this script but it does not work:
http://arcscripts.es....asp?dbid=14338
I've modified the script so it'll work for 9.3, however it does not produce any output files.
Cheers,
#2
Posted 28 January 2010 - 01:03 AM
Cheers
Dustin
Dustin
Dustin Edge
Snr GIS Analyst
AECOM Australia
#3
Posted 28 January 2010 - 02:00 AM
Red Geographics
Email: hans@redgeographics.com / Twitter: @redgeographics
#4
Posted 28 January 2010 - 06:47 AM
I used this simple script (9.3) to make batch project rasters in one folderanyone have a script which does this?
I bascially have 300+ raster that needs to be reprojected, it'll be awesome if there is a way to do automatically rather than one at a time.
I've tried this script but it does not work:
http://arcscripts.es....asp?dbid=14338
I've modified the script so it'll work for 9.3, however it does not produce any output files.
Cheers,
import arcgisscripting
gp = arcgisscripting.create(9.3)
gp.workspace = "c:/DEMs"
# Get a list of grids in the workspace.
#
rasters = gp.ListRasters("", "GRID")
for raster in rasters:
print "Processing: " + raster
outRaster = raster+"_reprjected"
Ouput_cs = "C:/ArcGIS/Coordinate Systems/Geographic Coordinate Systems/North America/North American Datum 1983.prj"
gp.ProjectRaster_management(raster, outRaster, Ouput_cs, "NEAREST", #, "NAD_1927_To_NAD_1983_NADCON", #)Hope this helps!
#5
Posted 28 January 2010 - 08:12 AM
#6
Posted 28 January 2010 - 09:24 AM
#7
Posted 28 January 2010 - 11:58 AM
anyone have a script which does this?
I bascially have 300+ raster that needs to be reprojected, it'll be awesome if there is a way to do automatically rather than one at a time.
I've tried this script but it does not work:
http://arcscripts.es....asp?dbid=14338
I've modified the script so it'll work for 9.3, however it does not produce any output files.
Cheers,
A quick gdal script will do this lightening fast. See www.gdal.org. Free, open source, and super powerful!
#8
Posted 28 January 2010 - 01:23 PM
gdal.org
#9
Posted 28 January 2010 - 02:37 PM
#10
Posted 28 January 2010 - 03:30 PM
gdalwarp -s_srs EPSG:4326 -t_srs EPSG:27700 infile.tif outfile.tif
Changing the EPSG codes as appropriate, of course (the above would warp from WGS84 to OSGB). But I'm hanged if I know how to do this for a directory of GeoTIFFs. I think it can be done with one command line, without the need for scripts, but I'm not sure. Any ideas people?
Regards, N.
#11
Posted 29 January 2010 - 01:55 AM
Changing the EPSG codes as appropriate, of course (the above would warp from WGS84 to OSGB). But I'm hanged if I know how to do this for a directory of GeoTIFFs. I think it can be done with one command line, without the need for scripts, but I'm not sure. Any ideas people?
If this would be on a Windows system you could use the magic of MS-DOS batch files. Specifically the "for" loop. Untested, but I think this may work:
@echo offfor %%f in (*.tif) do gdalwarp -s_srs EPSG:4326 -t_srs EPSG:27700 %%f c:\out\%%f
Copy it into a text editor, save it as "run.bat" (plain text) in the same directory as your tiff files and then go to the command line, navigate to that directory and type "run" (assuming you have Gdal installed of course)
Red Geographics
Email: hans@redgeographics.com / Twitter: @redgeographics
#12
Posted 29 January 2010 - 03:28 AM
If this would be on a Windows system you could use the magic of MS-DOS batch files. Specifically the "for" loop. Untested, but I think this may work:
@echo offfor %%f in (*.tif) do gdalwarp -s_srs EPSG:4326 -t_srs EPSG:27700 %%f c:\out\%%fCopy it into a text editor, save it as "run.bat" (plain text) in the same directory as your tiff files and then go to the command line, navigate to that directory and type "run" (assuming you have Gdal installed of course)
You are a true Dutch Master, Hans! This has been tested and it works. The only thing to add is that Gdal won't create the output directory ('C:\out' in this example) so this has to created in advance.
Regards, N.
#13
Posted 29 January 2010 - 03:57 AM
You are a true Dutch Master, Hans! This has been tested and it works. The only thing to add is that Gdal won't create the output directory ('C:\out' in this example) so this has to created in advance.
Thanks
Red Geographics
Email: hans@redgeographics.com / Twitter: @redgeographics
#14
Posted 29 January 2010 - 04:58 AM
dir /B *.tif | gdalwarp -s_srs EPSG:4326 -t_srs EPSG:27700 %%f c:\out\%%f
#15
Posted 29 January 2010 - 08:47 AM
The way I would do it would be without a batch-file, just directly in the "dos box" console (cmd.exe):
dir /B *.tif | gdalwarp -s_srs EPSG:4326 -t_srs EPSG:27700 %%f c:\out\%%f
This falls over with an error message:
ERROR 4: `%%f' does not exist in the file system, and is not recognised as a supported dataset name.
Regards, N.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account
New Zealand
Back to top
Australia
Netherlands
Vietnam
Sweden
United States
Canada
United Kingdom








