+ Reply to Thread
Results 1 to 13 of 13

Thread: Batch define projection

  1. #1
    Florian Stadtschreiber
    Join Date
    Feb 2011
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Default Batch define projection

    hi everybody,

    i would really appreciate if anyone could help with the following problem:

    i have app. 100 rasterdataset which do not have any projection defined (anyway i know they are xxxx because of the coordinates...) There´s a tool "define projection" in the arctoolbox. is there a possiblity to define projection in one step for all of the rasterdatasets in my workspace (something like batch define projection) in ArcCatalog 10???

    FS

  2. #2
    Matthew Nordhagen
    Join Date
    Oct 2010
    Posts
    71
    Points
    9
    Answers Provided
    0


    0

    Default Re: Batch define projection

    Hi - There are several ways you can approach this. This first way is to use the Batch option under ArcToolbox. If you right click on the Define Projection toolbox you will see an option in the context menu that's called "Batch". Here you can manually add the input dataset or feature class and it's appropriate Coordinate System. However, as I'm sure you can imagine, doing this for all ~100 of your raster datasets would take a significant amount of time. The second, and fastest method, is to use a Python script that will automate this for you. Below is the script that I made that will read all of the raster datasets from a workspace and define the projection for each raster dataset. Even if you are not too familiar with Python this script should be pretty straightforward but if you need any help please let me know.

    P.S. You can use either IDLE or PythonWin for this script.
    Attached Files

  3. #3
    Florian Stadtschreiber
    Join Date
    Feb 2011
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Post Re: Batch define projection

    please excuse, i´m quite new to using scripts... :-( moreover i´m using a german edition...

    so it would be a great help if you could tell me how to do this right: after donwloading des scriptfile i copied it into the .../arctoolbox/script folder. after that i made a new personal toolbox and added the script by right clicking - add script. until here it worked fine. so far so good, now if i use the script, it says "this tool has no parameters"... ?? what does this mean?

    Thx you very much for your help!!!

  4. #4
    Matthew Nordhagen
    Join Date
    Oct 2010
    Posts
    71
    Points
    9
    Answers Provided
    0


    0

    Default Re: Batch define projection

    Hi Florian - Sorry, I should have been a little more clear in my initial post. The reason you are getting "this tool has no parameters" is because the script that I sent is a standalone script. In other words it is not meant to be used to build a new personal toolbox within Arc. Instead you open this script with a program that's called IDLE. With the install of ArcGIS 10 IDLE is the default Python IDE (Integrated Development Environment) that lets you load scripts like the one I had sent you and run them outside of the ArcGIS Desktop environment. Below are directions that should get you where you need to go.

    1) Open IDLE. Either right-click on the Python script and select "Edit with IDLE" or navigate to the program's location which should be similar to the following "C:\Python26\ArcGIS10.0\Lib\idlelib\idlepyw

    2)Open your script if you haven't already done so. In the script you will see two variables. One called "prjfile" and another called "env.workspace". The variable "prjfile" contains the location for the projection file. I left the location of the projection file that I used to show you where the projections are located on your hard drive. Change this to match that of the coordinate system you want to use for you own data.
    The "env.workspace" variable is the workspace where all of your raster datasets are located. Change everything between the quotes to match the location of the folder on your hard drive with all of your raster datasets. Note: use forward slashes (/) instead of the usual back slash (\). So instead of C:\Program Files\ArcGIS it will be C:/Program Files/ArcGIS. Save your script.

    3) In the menu bar of IDLE navigate to "Run" and select select "Run Module". IDLE will sit for several seconds to gather all of the information that it needs. A second window called the Python Shell should pop up and, if everything has been done correctly, IDLE should start printing out the names of your rasters and whether or not it has defined the projection.

    Hopefully those directions are clear enough to get you on your way but if you have any questions or the script errors out let me know and we can go from there. Good luck.

  5. #5
    Ashley Mott
    Join Date
    Jan 2011
    Posts
    98
    Points
    1
    Answers Provided
    0


    0

    Default Re: Batch define projection

    Hi Florian, In addition to Matthew's great advice... There is an ESRI script that is the old batch define tool (attached). You can create your tool with the Add > Script... function that you mentioned. The attachment will be loaded in the "Script File" portion of the add script wizard. You can copy the parameters from the regular "Define Projection" tool (Input Dataset or Feature Class AND Coordinate System).

    Here is the walk-through: http://help.arcgis.com/en/arcgisdesk...0006000000.htm
    Attached Files

  6. #6
    Florian Stadtschreiber
    Join Date
    Feb 2011
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Default Re: Batch define projection

    i tried MTGIS script and it worked just fine the first time!! Tank you very much for your help, you´re great!

    @AshleyDIA: can you give me some hint how to copy the "define projection" tool parameters to my new "batch define projection script"?

    Ps: think i´m going to learn a bit more about using scripts in arcgis (i already learned there a standalone script´s an others within arc)
    Thx a lot!

  7. #7
    Ashley Mott
    Join Date
    Jan 2011
    Posts
    98
    Points
    1
    Answers Provided
    0


    0

    Default Re: Batch define projection

    Hi again Florian,
    See attached for the parameters I have for my Batch Define Projection tool.

    Good luck!
    Ashley
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	BatchDefinePrjParam.JPG‎
Views:	479
Size:	54.3 KB
ID:	4854  

  8. #8
    John Sobetzer

    Join Date
    Apr 2010
    Posts
    1,006
    Points
    235
    Answers Provided
    24


    0

    Default Re: Batch define projection


  9. #9
    Florian Stadtschreiber
    Join Date
    Feb 2011
    Posts
    4
    Points
    0
    Answers Provided
    0


    0

    Default Re: Batch define projection

    @johns: wow, that´s easy

  10. #10
    Osman Rodriguez
    Join Date
    Mar 2011
    Posts
    1
    Points
    0
    Answers Provided
    0


    0

    Default Re: Batch define projection

    Hi, could you help me please?, I tried to run your script but does not work, tell me "invalid syntax" ... I follow all parameters that you said, but still does not work, ... I'm using arcgis version 10 and I need to use this scrpy or the "BatchDefineSR.py" including in this version, or if you know how to works in the model builder, I will to thank you a lot .... slds
    Last edited by osmanrc; 03-16-2011 at 01:20 PM.

  11. #11
    Matthew Nordhagen
    Join Date
    Oct 2010
    Posts
    71
    Points
    9
    Answers Provided
    0


    0

    Default Re: Batch define projection

    Hi Osman - Just so I'm clear, are you using the script that I provided Florian in the beginning of this post? I just wanted to make sure since there were several other scripts after mine that were provided as alternatives. If you're referencing my script could you further explain the error? Ideally, could you post the script that you tried to run when you got the error? When it says "invalid syntax" it will usually provide the line of code that's the issue (it's usually found several lines about the "invalid syntax" error). If you could provide those two pieces of information I can help you further. Thanks!

  12. #12
    Frank Vignati
    Join Date
    Apr 2010
    Posts
    123
    Points
    10
    Answers Provided
    1


    1

    Default Re: Batch define projection

    Quote Originally Posted by fstadtschreiber View Post
    hi everybody,

    i would really appreciate if anyone could help with the following problem:

    i have app. 100 rasterdataset which do not have any projection defined (anyway i know they are xxxx because of the coordinates...) There´s a tool "define projection" in the arctoolbox. is there a possiblity to define projection in one step for all of the rasterdatasets in my workspace (something like batch define projection) in ArcCatalog 10???

    FS
    you can do this easily with model builder
    make a model that iterates the rasters in a workspace (directory) and applies a projection
    Attached Thumbnails Attached Thumbnails Click image for larger version

Name:	DefineProjection.png‎
Views:	456
Size:	5.7 KB
ID:	5428  

  13. #13
    Lyndy worsham
    Join Date
    Jun 2010
    Posts
    72
    Points
    2
    Answers Provided
    0


    0

    Default Re: Batch define projection

    This is an awesome, time saving tool! Thanks so much!

    My only suggestion is that it would be good if a message could pop up that the process is completed. The window just closed so I wasn't sure if it worked or not at first.

    Lyndy

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts