Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

If I have a shapefile or geodatabase featureclass that has fields that I want to permanently reorder, is there a tool, script, or utility that will help me quickly accomplish this task?

Generally I know you have to create a new field, then populate it with the old values, then delete the old field. I am hoping there is something already created out there that will help with this. Assuming you don't have FME or another ETL tool available, what is the next best suggestion?

This is NOT a view level change (ie- drag/drop the fields in order), but rather write out to a new shapefile or featureclass. Thanks.

share|improve this question
    
I find it hard to believe, but I can't find a way to do this. What's your use case for needing to re-order fields? Re-ordering fields on the fields tab of the layer properties in ArcMap isn't a solution? –  Derek Swingley Feb 7 '11 at 20:16
2  
The reordering of the fields is because the data will not be used in ArcMap, but with a less-sophisticated mapping software that 1) uses shapefiles and 2) does not allow for reordering on the client side and 3) the client needs to see the key attributes show up at the top of the "identify" tree. –  RyanDalton Feb 7 '11 at 20:32
    
Just edited my previously deleted answer. Hopefully you're not scared of the command line ;). –  Derek Swingley Feb 7 '11 at 21:23
    
same question? gis.stackexchange.com/questions/5839/… –  SaultDon Feb 7 '11 at 22:17
2  
@SaultDon- this is not the same question. You referenced a question that wants to sort RECORDS (rows), but I want to sort FIELDS (columns). –  RyanDalton Feb 7 '11 at 23:01

11 Answers 11

up vote 11 down vote accepted

I'm pretty sure you can do this with Feature Class to Feature Class by re-ordering fields in the field map section of the tool.

Edit: FC2FC doesn't do this but...ogr to the rescue.

I just confirmed that ogr2ogr can do this. Specify your field name order on the -select switch. For instance, if I have a shapefile with two fields, "Name" and "FolderPath" (in that order), but I want a new shapefile with "FolderPath" first I would do this:

C:\Temp>ogr2ogr -f "ESRI Shapefile" re_order_ogr.shp re_order1.shp -select "FolderPath,Name"
share|improve this answer
2  
While it wasn't as user friendly an option as I had hoped for, it definitely does the trick. I have created an ArcGIS python script that helps build the inputs for it, and the user just has to include the -select "field1,field2,etc" option. You can download it at resources.arcgis.com/Resources2010/gallery/file/geoprocessing/… –  RyanDalton Feb 8 '11 at 18:45
2  
Nicely done! Thanks for sharing. –  Derek Swingley Feb 8 '11 at 19:26

X-Ray arcmap add in have a tool for reorder fields of Geodatabes formatx-ray reorder fields tool here

share|improve this answer

I have had a similar issue, and the fastest way to permanently reorder data fields, if you already have QGIS, is to use the 'Table Manager' plugin as previously suggested.

It is simple to install plugins and is user-friendly, as described on the page below:

http://www.qgistutorials.com/en/docs/using_plugins.html

It allows you to move the attributes in a specific order, rename the fields, insert any new fields and replicate them. It also allows you to save the original file, or rename it and save it differently from the original.

enter image description here

This was a quick and convenient solve to my attribute table management problem, and is highly recommended, especially for files with a large number of attributes associated with it.

share|improve this answer

The QGIS "Table Manager" Plugin now also has the ability to perform this task easily with no command line necessary.

share|improve this answer

I'm a bit late to the party on this one, but I'm surprised that no one has mentioned the ESRI Geodatabase Diagrammer.

A resource provided by ESRI for editing the XML structure of your geodatabase and files. As far as I'm concerned it's essential if you're working on anything where design has to be perfect (long term project). It'll keep you from having to re-create files continually after making a simple mistake.

share|improve this answer
1  
Did you see the comment (to the question itself) stating that this was not a database reorganization, but rather is needed to export the data? –  whuber Jul 30 '12 at 13:29

Open the .mdb file in MS Access and reorder the fields using drag and drop in 'Design View'

Though ESRI discourages editing a database in Access ESRI link

share|improve this answer
2  
Welcome to our site, Karey! Isn't this the same answer Matt Wilkie gave in this thread 18 months ago (gis.stackexchange.com/a/5879)? –  whuber Jul 30 '12 at 13:28

Try OGR2OGR. You can pass an SQL query, and put the fields in the order you want them.

ogr2ogr outdataset indataset -sql "SELECT src_field1 AS dst_field1, src_field2 AS dst_field2 FROM sourcelayer"

Just tested this, and it works fine!

FYI, The easiest way to install OGR is via FWTools.

share|improve this answer

For the reference: MapInfo can also do it out-of-the-box. Just open the DBF and reorder the fields permanently. http://www.dbf-editor.com does it too ($40). Other DBF editors can probably do it too.

share|improve this answer
    
in this line, infolib should probably work too (convert to ascii (csv), rearrange to suit, re-convert back to info or dbf), as long as you're willing to live with the limitations of the .dbf file format. –  matt wilkie Jun 9 '11 at 22:11
    
You mean living with the limitations of the CSV format? DBF is the starting point for this question... –  Uffe Kousgaard Jun 10 '11 at 11:39
    
I meant dbf limits, thinking specifically that csv has no limits on field name length or record value lengths, and that starting point was file gdb, but re-reading the Q I see "shp" is mentioned in the title. So, limits all around ;-) –  matt wilkie Jun 10 '11 at 18:02

MakeQueryTable will let you define the order of your fields for a table or FC (Geodatabase only). The order that you specify the fields is the order of the output. I find this tool difficult to use. YMMV

Arctoolbox, data management tools, layers and table views, make query Table

share|improve this answer

The ET GeoWizards tool will do this, and it looks like the free version will do it without any limitations on the number of features.

share|improve this answer

Export the feature classes to an empty personal geodatabase (drag and drop is fastest), open the .mdb in Access, re-order the fields, then export back to shape or file geodatabase. You can use the same method to rename the fields. Be careful though, only work on copies, it is easy to screw everything up.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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