Tag Info

Hot answers tagged

11

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 ...


10

I think you need to actually use FieldMappings.replaceFieldMap to get it to persist. Example from help topic Mapping input fields to output fields: # First get the TRACT2000 fieldmap. Then add the TRACTCODE field # from Blocks2 as an input field. Then replace the fieldmap within # the fieldmappings object. # fieldmap = ...


4

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.


3

When you bring in a csv, Arc does its best to determine the appropriate field types and as you have found it doesn't always get it right. One solution is to use a schema.ini file (see bottom of page) to explicitly set the field types for your columns. There are several related (duplicate?) questions here on the GIS SE if you search for 'schema.ini'. More ...


3

Note: I've edited this answer to correct a mistake highlighted above The problem is you are removing the field map to the table, and not removing the fields from the field map. So, it removes the first (and only) fieldmap, then it doesn't know what to do when you tell it to look for the next fieldmap. What you need to do is create a new fieldmap and add ...


3

Not at the moment, but this is a planned for 2.1 or 2.2. You only option at the moment is a custom form with some Python logic to handle that kind of thing.


3

To keep up with folks :) some alternatives Since you store your data in an enterprise geodatabase (or DBMS without Esri component) - why not take advantage of SQL? This is way faster than running any GP tool or arcpy (for copying data). Run some SELECT INTO statements limiting what columns you want to take and then run arcpy only to copy the tables with ...


3

Another alternative is to create a feature layer containing only the fields you want, then use arcpy.CopyFeatures_management() or arcpy.FeatureClassToFeatureClass_conversion() to copy the result to a new feature class. I've written a function called make_skinny() (with two wrappers, make_skinny_feature_layer() and make_skinny_table_view()) that takes a list ...


3

I have noticed that the DeleteField tool can be very slow when there are a lot of fields. One thing I have done in the past is created a template table that just has the fields I needed and just copy that blank table and use the arcpy.management.Append() to write features to the template table. Seemed to work pretty well.


3

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


3

X-Ray arcmap add in have a tool for reorder fields of Geodatabes format


2

The last sample in the Mapping input fields to output fields help topic has a python example of removing a field from a field map. Here's the relevant code: fieldmappings = arcpy.FieldMappings() <snip> fieldmappings.removeFieldMap(fieldmappings.findFieldMapIndex("TRACTCODE")) That is for 10 but it looks like there were similar methods at 9.3: ...


2

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 ...


2

It's a feature not a bug. Seems that you do not need to add the SHAPE field to mapping, it will always be included and remain in the feature class. You can't seem to rename it either.


2

I've tried to do this with code and had a similar situation as yours. Arc kept trying to merge a text field with a integer field because the fields were named the same, even though the data type was different. Here is an example: I had to bring all the shape files I wanted to merge into the merge tool and go through the field mappings to make sure that ...


2

Well this script might be a bit convoluted but it worked for me. You may need to tweak with the fldConvTypes variable - I'm not sure if it works for Date and/or Guid field types. Essentially it figures out all the fields between all the feature classes, and throws them in a list. It then iterates through all the fields in the feature classes once again. If ...


2

I think this will perform what you are looking for. It iterates the first two fields of each row and compares each value to the dct. dct = {} subregion = 0 with arcpy.da.UpdateCursor(fc_in, (fld_o, fld_d, fld_name1)) as cursor: for row in rows: for i in row[:2]: if not i in dct.keys(): dct[i] = subregion ...


2

You don't actually need to express the geometry field ('SHAPE') in the fieldmappings. It will come along for the ride. (If you try to do something equivalent using a tool dialog that uses a fieldmappings, you'll notice the geometry field isn't added to the control.) So, given that this field is in your config file, just add an if to exclude it. for ...


2

I'm not sure why that isn't working for you, but why not try an additive approach instead of a removal approach (see code below). I confess I haven't tested this code to make sure it will work, but I'm pretty sure it will. EDIT: I've tested this script out on a test dataset and it works fine. I'll continue investigating what the problem is with your ...


1

You can find an interesting article from ESRI Python Team : Otherwise the "Field Mappings" are explained here (with usefull examples at the end of the page):


1

I encountered the same problem after upgrading to v10.1 for nearly the same scenario... errors on Date columns when using arcpy.FeatureClassToFeatureClass_conversion with joined layers in Python script. I'm using the following workaround: Use arcpy.FeatureClassToFeatureClass_conversion, but omit the field map parameter. I'm storing the output feature ...


1

I dislike the ModelBuilder environment for many reasons such as this one. It has a very convoluted validation system that tends to get in the way more than it helps. I suspect it is trying to be "helpful" by noticing you updated the data source of some upstream data element and "helpfully" wipes out your field mappings. Perhaps you could export your working ...


1

Is probably your understanding about FieldMap is wrong. Because one field relation with one FieldMap object,so you need create nine FieldMap object in your case.In addition,inFields is a list,you can not use field.name. Modify the code as follows,I think that the result you want to obtain. import arcpy fClasses = [] i=0 #Loop through MyGDB.gdb and add ...


1

I found that I simply needed to split the field selections and then iterate through the list using field mapping. paramInWells = arcpy.GetParameterAsText(0) paramInFields = arcpy.GetParameterAsText(1) paramInFieldList = paramInFields.split(";") paramOutExcel = arcpy.GetParameterAsText(2) arcpy.SetProgressorLabel("Processing...") arcpy.AddMessage("\nAdding ...


1

Following on from the previous arcpy SearchCursor return a OBJECTID value not as an integer Dim pQF As ESRI.ArcGIS.Geodatabase.IQueryFilter = New ESRI.ArcGIS.Geodatabase.QueryFilter() pQF.WhereClause = "BQ no. = '22/22' and Segment ID = '22/22-1'" 'exactly the same as Select by Attributes' Dim pCur As ESRI.ArcGIS.Geodatabase.ICursor = pTable.Search(pQF, ...


1

max_UID_length = 0 field_mappings = arcpy.FieldMappings() for table in dbf_list: fields = arcpy.ListFields(table) for field in fields: if field.name == "UID": if field.length > max_UID_length: max_UID_length = field.length field_mappings.removeAll() field_map = ...


1

The FieldInfo() object seems to me to be more appropriate than the FieldMappings if you want to drop fields from your input. It allows you to modify some properties of your input fields when passing them to the output. One of these properties is visibility (if a field is not visible, it won't be passed to the output). It is used among other by the Make ...


1

Try Orux maps. It has the capability to download tiles for offline use, load KML overlays and load raster for background imagery. Not sure though it has all the functionality you need in terms of KML attributes but it is worth a try.


1

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.


1

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



Only top voted, non community-wiki answers of a minimum length are eligible