Jump to content

 
Photo

Batch Project Raster Tool

- - - - -

  • Please log in to reply
19 replies to this topic

#1
beefcrab

beefcrab

    Newbie

  • Validated Member
  • Pip
  • 9 posts
  • New Zealand

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,

#2
Dustin Edge

Dustin Edge

    Contributor

  • Validated Member
  • PipPip
  • 31 posts
  • Australia

Any tool in ArcToolBox has a Batch mode that can be accessed by right-clicking on it.

Cheers
Dustin
Kind Regards,

Dustin


Dustin Edge
Snr GIS Analyst
AECOM Australia

#3
Hans van der Maarel

Hans van der Maarel

    CartoTalk Editor-in-Chief

  • Admin
  • PipPipPipPipPipPipPip
  • 3,833 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Cartography, GIS, history, popular science, music.
  • Netherlands

Have you considered looking outside of Arc for solutions? For example: FME can do this easily and Global Mapper can be scripted to take on a task like this.
Hans van der Maarel - Cartotalk Editor
Red Geographics
Email: hans@redgeographics.com / Twitter: @redgeographics

#4
Ninomax

Ninomax

    Contributor

  • Validated Member
  • PipPip
  • 37 posts
  • Vietnam

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,

I used this simple script (9.3) to make batch project rasters in one folder

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
frax

frax

    Hall of Fame

  • Associate Admin
  • PipPipPipPipPipPipPip
  • 2,299 posts
  • Gender:Male
  • Location:Stockholm, Sweden
  • Interests:music, hiking, friends, nature, photography, traveling. and maps!
  • Sweden

You can also create a model in model builder for this...
Hugo Ahlenius
Nordpil - custom maps and GIS
http://nordpil.com/
Twitter

#6
johnnyh

johnnyh

    Contributor

  • Validated Member
  • PipPip
  • 43 posts
  • United States

GlobalMapper has an excellent 'Batch Convert/Reproject' that works great... I am more and more doing conversions, clips, rectifies in GM rather than Arc, ,which has never worked well for simple tasks IMO.

#7
Darren Cope

Darren Cope

    Contributor

  • Validated Member
  • PipPip
  • 12 posts
  • Canada

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
kjmcgrath

kjmcgrath

    Newbie

  • Validated Member
  • Pip
  • 6 posts
  • Gender:Male
  • Location:Madison, Wisconsin
  • United States

Some good suggestions above already... Hopefully one more to add to the list. The GIS libraries GDL/OGR are open-source code libraries with little overhead allowing simple tasks like this to be done quickly especially on multiple files (without going through the behemoth of Arc as it is much more intense since it has many more services/tools/memory overhead etc) accessed through python (which also can script for Arc, in a more object oriented way so learning this language is not a dead end pursuit.) GDL and OGR (the vector GIS library) has good documentation and a fairly large following for support. Hope this helps and is not something everyone already knows about.

gdal.org

#9
beefcrab

beefcrab

    Newbie

  • Validated Member
  • Pip
  • 9 posts
  • New Zealand

thanks for the help, I'm still a complete newbie when it comes to scripting and manipulating geoprocessing tools (as you can already see.) Will look into the options and report back to you guys.

#10
Nick H

Nick H

    Legendary Contributor

  • Validated Member
  • PipPipPipPipPip
  • 307 posts
  • Gender:Male
  • Location:Caversham, Reading, England.
  • United Kingdom

I'm pleased that GDAL has been mentioned. For a one-off projection/reprojection the command line would be something like this:

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.
Caversham, Reading, England.

#11
Hans van der Maarel

Hans van der Maarel

    CartoTalk Editor-in-Chief

  • Admin
  • PipPipPipPipPipPipPip
  • 3,833 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Cartography, GIS, history, popular science, music.
  • Netherlands

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)
Hans van der Maarel - Cartotalk Editor
Red Geographics
Email: hans@redgeographics.com / Twitter: @redgeographics

#12
Nick H

Nick H

    Legendary Contributor

  • Validated Member
  • PipPipPipPipPip
  • 307 posts
  • Gender:Male
  • Location:Caversham, Reading, England.
  • United Kingdom

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)


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.
Caversham, Reading, England.

#13
Hans van der Maarel

Hans van der Maarel

    CartoTalk Editor-in-Chief

  • Admin
  • PipPipPipPipPipPipPip
  • 3,833 posts
  • Gender:Male
  • Location:The Netherlands
  • Interests:Cartography, GIS, history, popular science, music.
  • Netherlands

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 ;) It's funny that even after all those years of (Windows) GUI developments, there's still stuff you can only do on a command line...
Hans van der Maarel - Cartotalk Editor
Red Geographics
Email: hans@redgeographics.com / Twitter: @redgeographics

#14
frax

frax

    Hall of Fame

  • Associate Admin
  • PipPipPipPipPipPipPip
  • 2,299 posts
  • Gender:Male
  • Location:Stockholm, Sweden
  • Interests:music, hiking, friends, nature, photography, traveling. and maps!
  • Sweden

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

Hugo Ahlenius
Nordpil - custom maps and GIS
http://nordpil.com/
Twitter

#15
Nick H

Nick H

    Legendary Contributor

  • Validated Member
  • PipPipPipPipPip
  • 307 posts
  • Gender:Male
  • Location:Caversham, Reading, England.
  • United Kingdom

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.
Caversham, Reading, England.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

-->