|
POST
|
Using row or r is fine. I think the problem is that the comparison continues after the row has been deleted. Once deleted, row would be undefined for the comparison to the next r[0] value. You would need to break out of the for loop once the del(row) operation takes place. That also raises the question about the comparison logic. If you do not query the table for any specific records, than I would expect many records to not match your row values, and the row would virtually always be deleted. A dictionary would help with this, since doing a if not row[0] in dict: compares to all the of dictionary keys you previously loaded from the entire table at once, not to just one row at a time in the comparison table.
... View more
04-21-2015
07:45 AM
|
2
|
3
|
3758
|
|
POST
|
row is use in many part of your code. Which specific line is throwing the error? Also, do not use nested cursors. They are horribly inefficient and in my opinion should never be used. Instead first use a cursor to load the entire source you want to match into a dictionary and then run an updatecursor on the data that needs to match it using the dictionary to compare the values. See my blog on the subject here for some ideas of how this can be set up.
... View more
04-21-2015
07:26 AM
|
2
|
5
|
3758
|
|
POST
|
Use Attribute Assistant to do the auto numbering. It comes as part of the Local Government Information Model (LGIM) templates like the Address Data Management template (you don't need to the the LGIM). To create an auto increment number use the Attribute Assistant toolbar, the GenerateID table and DynamicValue table. Press the download button to get to the link to download it. After extracting the files double click the esriAddin files for Attribute Assistant and Address Management to install them while ArcMap is closed. In the GenerateID table you add a row with the feature class name, the current number of the sequence in your table. Use 0 if you are starting with nothing numbered, but this only works for blank feature classes/tables. Use the last existing number of an existing sequenced field if it already has records (see the autoincrement calculation to initialize an existing long field). OBJECTID * Sequence Name Sequence Counter Interval Value Comments 20 WHYDRANT 44448 1 <Null> Then in the DynamicValue table you enter the feature class/table name holding the feature class name (WHYDRANT), the field to be incremented (FACILITYID), the Value Method (GENERATE_ID), a Value string (WHYDRANT|0|[seq] - meaning increment a normal number with no leading zeros stored in the WHYDRANT feature class), and make On Create True and all other options false. OBJECTID * Table Name Field Name Value Method Value Info On Create On Change (Attribute) On Change (Geometry) Manual Only Rule Weight Comments 147 wHydrant FACILITYID GENERATE_ID WHYDRANT|0|[seq] True False False False <Null> <Null> Add both of these tables to your map from the directory you extracted it to in the \AddressDataManagementLG\MapsandGeodatabase\LocalGovernment.gdb. Also add the feature class (like wHydrant under the WaterDistribution dataset). Now add the Attribute Assistant toolbar (right click toolbar area and choose Attribute Assistant) and make sure that the first button is active (the red exclamation mark in the icon disappears). Add a new feature and notice the next number in the series for your field was added.
... View more
04-17-2015
04:55 PM
|
2
|
0
|
2636
|
|
POST
|
Are they two columns on the same page aligned in rows already? If so, then I do not understand the problem, since you could just concatenate the two columns together on the same row. If they are on separate pages or in separate spreadsheets then you would first need to break apart the address from each component first and do a match on the address that is common in both using ZLookup. I have attached a spreadsheet that shows how to parse the two columns if they were on separate spreadsheet pages and then do a match using VLookup. After matching, just concatenate as needed.
... View more
04-15-2015
06:33 PM
|
2
|
1
|
4726
|
|
POST
|
I am not clear what I am looking at. Are these two separate spreadsheets, two separate columns, two separate pages? Are the values in each set in a single field each (set1 and set2) or are the sets made up of separate fields (like x, y, address, unique ID, address)? The VLookup can do this if the address portion of each set is separated out.
... View more
04-15-2015
05:57 PM
|
1
|
3
|
4728
|
|
POST
|
Jake: I see that your tool is trying to automate the Add Field, Calculate Field, Delete Field, Alter Field (to rename it) workaround steps that normally have been done when the original feature class/table is changed rather than creating a new fc/table. The Alter Field step of the tool will only work if the input is within a geodatabase. For shapefiles you have to do a second Add Field, Calculate Field, Delete Field to get the original field name back. Your tool should test the input to determine if the Alter Field step can be done and otherwise do the 3 alternative steps. Of course, this workaround technically is not altering the original field, just the original fc/table. The unfortunate consequence of this workaround is that the fields are reordered, with the new version of the field being added to the end of the fc/table's field set rather than remaining in its original position, but if retaining the ObjectIDs of the original features/rows is important, your approach would be necessary. The only way to keep the field order is to create a new fc using a tool like the Feature Class to Feature Class tool as Gabriel suggested, but then all ObjectIDs will be renumbered (and I think that GlobalIDs also regenerate or cease to function).
... View more
04-15-2015
08:16 AM
|
1
|
0
|
11493
|
|
POST
|
Shapefiles field names have a maximum character length of 10 characters. This is a requirement of the format and cannot be overridden. Therefore there is no way to convert a field with a name longer than 10 characters into a shapefile without changing the name to fit the format requirement. If the person I am providing the data to users ArcMap, I zip a file or personal geodatabase. If I must export to a shapefile I usually copy and paste one record from the original feature class into a spreadsheet and send the spreadsheet along with the shapefile. The spreadsheet would show what the full field names were before conversion to the shapefile. You could set up aliases in a layer and export a layer file and send that layer file to the other user to display a readable field name, but the underlying field name will be truncated.
... View more
04-15-2015
07:26 AM
|
2
|
1
|
17735
|
|
POST
|
After looking more closely at the IName interface I see that it has an Open method that can instantiate the workspace or dataset, even when no feature class is included in the IName. The IName help says: "A Name object is a persistable software object that identifies and locates a geodatabase object such as a dataset or a workspace or a map object such as a layer. A Name object supports an Open method that allows the client to get an instance of the actual object (for example, the dataset or workspace) given the name object. A name object thus acts as a moniker that supports binding to the named object. The geodatabase supports methods on workspaces that hand out name objects that can be used by browsing clients to display the names of datasets in the workspace and to instantiate any specific dataset." I suppose I would have to extract just the IFeatureDatasetName portion of the full tool output and cast that to IName prior to using the Open method, since otherwise the full output Name in the IGPValue would include a feature class that does not yet exist. So I guess I can go from IGPValue to IName to IFeatureDatasetName, back to IName, then use the IName Open method to create an instance of the IDataset and then get an IGeodataset (or possibly open the IGeodataset directly using IName) and finally get the Spatial Reference.
... View more
04-14-2015
08:48 AM
|
0
|
0
|
4101
|
|
POST
|
Ken: Thanks for pointing that out. I never looked at the snippets and all help searches on IFeatureDataset never led me to IGeoDataset to get to the Spatial Reference. Can an IFeatureDatasetName be cast to an IFeatureDataset, IDataset or IGeoDataset directly? Is there a better way to take the text path to get one of those interfaces? It seems so convoluted with no obvious bridge between the two interfaces. I appreciate the other suggestion, but the point of this post is that no feature class exists to pass to any method. I intend to create one, but until the tool completes no feature class would exist in the feature dataset. Anyway, the IGeodataset interface is will do what I need if I can convert a workspace path to that interface.
... View more
04-14-2015
06:19 AM
|
0
|
1
|
4101
|
|
POST
|
I am trying to create a custom geoprocessing custom tool and have set the output parameter to create a new feature class. If the user chooses an output to a feature dataset path that exists, but contains no actual feature classes or other data, how can I discover the spatial reference of the feature dataset? I need the output spatial reference to determine whether or not the dataset will contain feature classes with a Projected Coordinate System (PCS) or Geographic Coordinate System (GCS) and generate an error if the dataset output will use a GCS. I do not want to create a feature class temporarily just to determine the feature dataset's spatial reference. From the IGPValue of the output I can cast to the IName interface and find out if the output will be stored in a feature dataset by attempting to cast IName to an IFeatureDatasetName, but I am not sure how to get from that interface to the spatial reference of the feature dataset. Even if I could navigate to the IFeatureDataset interface I don't see a method that would let me extract the spatial reference of the feature dataset. Any ideas on what set of interfaces gets me from the path string of an existing feature dataset to the spatial reference of that feature dataset? It seems like the spatial reference should be one of the main properties of a feature dataset, since one of the primary characteristic of a feature dataset is that nothing can be stored within it that does not match the feature dataset's spatial reference. I prefer to use VB.Net, but any .Net code that shows the interface path I need to use is fine.
... View more
04-13-2015
05:31 PM
|
0
|
5
|
9386
|
|
POST
|
Ben: Your suggestion will not work, since there are duplicate values in every individual column and only the first row with a given column value would be returned for each VLookup, which in most cases would have nothing to do with each other. Only the concatenation of all 4 columns will look up the correct row in the original spreadsheet. There is no way to do this without at least creating a new column in the original spreadsheet. Once that was done perhaps the VLookup could be written in the new sheet without adding a column, but that unnecessarily complicates the formula in a way that would waste my time with debugging unneeded complexity. The approach I suggested was easy to set up.
... View more
04-13-2015
08:42 AM
|
1
|
2
|
1958
|
|
POST
|
In order to do this in Excel you would need to create a new column in both tables that concatenates the four look up columns together first. They you would use the VLookup formula to fill in column F (since you should insert the concatenated look up column into a new column A) After inserting a new column A, the formula for the concatenation in cell A2 would be =CONCATENATE(B2,";",C2,";",D2,";",E2) Then drag this formula down the column to copy it and increase the row number The VLookup formula would start in the new sheet's column F2 (I/O) and would be basically: =VLOOKUP(A2,Sheet2!A$2:F$6,6,FALSE) The F$6 portion of the formula should have the bold number edited to change it to the last filled in row number in the original sheet. Sheet2 should match the sheet name of the original data in your spreadsheet. Then drag this formula down the column to copy it and increase the A2 row number. Convert the formulas to values before trying to open the spreadsheet in GIS, since GIS does not understand Excel formulas, only hard values.
... View more
04-13-2015
07:30 AM
|
1
|
6
|
1958
|
|
POST
|
I appreciate getting information that brings me up to date on what is happening with da cursors in the latest versions of ArcGIS. I don't have 10.3, and only recently got 10.2.1 installed. I tried the Order By option at 10.1 with the release of the da cursor, but I gave up on it. I have not tried it since then. This has happened to me several times where I try something that should work in an early release and discover that it has serious issues that make it either fail or perform horribly. Once I give up on code that fails me it can be hard to give Esri another chance. Generally figuring out a workaround took so much effort that I resent the original method that should have worked for wasting so much of my time. If a workaround is very effective, then even if the workaround is complex, I forget to even consider the possibility that the original approach that is simpler might have been fixed in the latest release. Anyway, thanks for bringing me up to date.
... View more
04-10-2015
04:26 PM
|
0
|
1
|
2193
|
|
POST
|
She attached a png to her post called notworking.png. It shows a table that appears to following no particular order. If the table shown in that picture is following a sorted order it must be based on a multifield sort. My code can increment to follow a multifield sort by just replacing the OID@ field name with the alternative secondary sort field to control the multifield sort.
... View more
04-10-2015
01:44 PM
|
0
|
1
|
7444
|
|
POST
|
Dan: I get this by looking at her picture. She wants whatever order the table view randomly picks without any sorting of any field to be sequentially numbered to fit that (dis)order. She has not mentioned any field that she would like to order by and as far as I could see her picture was not sorted based on any field value at all. The autoincrement code always uses ObjectID order, because that is the order that the field calculator and any unsorted cursor always uses to process records in a table.
... View more
04-10-2015
01:34 PM
|
1
|
3
|
7444
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 03-24-2026 11:37 PM | |
| 1 | 03-24-2026 08:01 PM | |
| 7 | 02-23-2026 08:34 AM | |
| 1 | 03-31-2025 03:25 PM | |
| 1 | 03-28-2025 06:54 PM |
| Online Status |
Offline
|
| Date Last Visited |
4 weeks ago
|