Labeling based on Location

4346
6
07-29-2010 12:23 PM
PaulBoehnlein
New Contributor II
Hello,

I have a map containing about 150 parcels.  I would like to label the parcels based upon their locations, with 1 being the Northwestern-most parcel and 150 being the Southeastern-most.  Unfortunately I do not have a field that corresponds to that scheme.  Is there an automated solution to this type of problem, or will I be forced to manually populate a new field?

Thanks in advance.
Tags (2)
0 Kudos
6 Replies
RichardFairhurst
MVP Honored Contributor
Hello,

I have a map containing about 150 parcels.  I would like to label the parcels based upon their locations, with 1 being the Northwestern-most parcel and 150 being the Southeastern-most.  Unfortunately I do not have a field that corresponds to that scheme.  Is there an automated solution to this type of problem, or will I be forced to manually populate a new field?

Thanks in advance.


You will be forced to either populate a field or create a join table derived from your original features.  This may not have to be done completely manually, since you can create a field that stores an X/Y Coordinate for each record that can be sorted and summarized to get an order (although I believe on the north/south level in the northern hemisphere you will have to apply an adjustment to make a summary table order correctly from north to south and not from south to north for most coordinate systems.)  The final aspect is how you want to move from point to point.  If you want to move just northerly to southerly and only use easterly/westerly to break ties, that is an easy sort on the (adjusted or decending) Y coordinate and then on the X coordinate.  If you want to move southerly only if the easterly /westerly plane is less pronounced (or something similarly tricky) you may be looking at something more manual or radius based.  One possible approach would be to pick your northwesterly most point as a start and then get simple distances (SQR((X1 - X2)^2 + (Y1 - Y2)^2)) to each of the other points relative to that point which would create a sortable radius of movement away from that point.  Anyway there are different algorithms for doing this depending on what you want.

The first step is to calculate an X and Y coordinate.  Concatenate them as a standard formatted string field to act as a join (or use your parcel ID as a join field in the way mentioned below).  Sort them or summarize them.  Summarize and/or Frequency are nice to use for this kind of problem, because the OBJECTIDs will be numbered from 1 to n rows according to whatever field sort order you requested.   (Frequency is required if you need an output sort order on more than one field and requires an ArcInfo licence),   The resulting summary or frequency need a join field outputted so you can join the result table back to the original to get your ordered label numbers to print or to calcuate back to your original table.  The summary/frequency can export a join field that does not affect the sort order by using a First summary for a string join field or Min for a numeric join field.  From there it is up to your imagination.  (I always have to think in terms of algorithms like this since my Parcel set is over 3/4 million parcels and nobody ever wants the same set of parcels twice, so there is no way can I approach something like this manually).  Gotta go.

Rich
0 Kudos
PaulBoehnlein
New Contributor II
Thanks Richard, I'll give it a try.
0 Kudos
RichardFairhurst
MVP Honored Contributor
In responding to another users problem I found a tool that would be ideal for the step of creating the sequentual numbers you want to display after you have created the fields you need to get the spatial order sorting effect you want.

You can create a new table that permanently sorts your data the way you want with the free Python script below created by Chris Snyder (designed for ArcGIS 9.3).

http://arcscripts.esri.com/details.asp?dbid=16771

I just tried the script. It permanently sorted the data. The ObjectIDs for the new feature class were all ordered and sequential according to my sort order choices (Ascending or Descending on up to 3 fields). The Output respected both Selection sets and Definition queries when a layer was the source and had imposed these limitations on the full feature set.

My only critique of the script it that it does not appear that the script preserves the original feature ObjectIDs of the original data for purposes of doing a join back to your original feature class/table (assuming you need to preserve that table). If you can modify the original table's schema you could first create and calculate a field that stores the original ObjectIDs in a Long Interger field. The tool output will contain that field, which would allow you to do a join back to the original for labeling, symbolizing or transfering the new sequential IDs back into a field located in your original feature class.

If you cannot modify your original schema, the tool could probably be reworked a little to give you the option to preserve the original ObjectID in a user defined field added to the output by the tool (after the script first makes sure that your original is a geodatabase or feature class type that supports these IDs). That would make the tool much more flexible so that it could do joins back to data that cannot have its schema altered or that is otherwise protected from user overwrites. This is also useful for where you want to use the output feature classes/tables to help you process and analyze multiple selections sets against your original data that take into account these sequential IDs and use the previous selection to somehow constrain your next selection. (After I get a bit more comfortable with Python I will probably try to do that modification if someone else does not post it first).

The script comes with a toolbox to make it easily accessible in ModelBuilder, but I found that the tool initally gave an error when I tried to run it. I had to go into the script properties and correct the source by browsing to the location where I had stored the script.

(Summarize and Frequency still have their uses where you need sequencing that is based on attribute aggregation and not for one-to-one record matches.. However, for one-to-one record matches the above tool is better).

(Another useful related Python tool that can permanently reorder the attribute fields of a Feature Class or Table in a copy can be accessed through a link in the last post of the thread below:

http://forums.esri.com/Thread.asp?c=...=4#msgid951126

Before using the script in ArcGIS 9.3 go into the Python editor and edit to the last line as suggested in the post.  Great for when you realize you really wanted to permanently add a field at the beginning or middle of your feature class/table for better organizing related fields after you already have created a schema with a large number of fields.  Both of these tools should come as out of the box tools for ArcCatalog from ESRI IMHO.  It would have saved me loads of frustration with ArcCatalog.)

I hope this helps.

Rich
0 Kudos
RichardFairhurst
MVP Honored Contributor
At ArcGIS 10 there is a sort tool that can do spatial sorts, but it currently requires an ArcInfo licence.  Probably both of those things don't help you at this point, but keep it in mind.  Still wiht an Y / X field pair sort you should be able to accomplish something like the Upper Right, Upper Left, Lower Right, and Upper Left sorts.  Reversing the X and Y order would give priority to east/west movement over north/south movement.

I have not seen the results of the ArcGIS 10 tool myself, so I cannot be sure they don't have a fancier algorithm under the hood.  They also have a APEANO option that I do not fully understand. 

Anyway, with a set of X / Y fields you could previsualize the sort in a tableview and walk through the features to see if the order did what you wanted with any of the above sort orders.
0 Kudos
PaulBoehnlein
New Contributor II
I've just revisited this workflow and the Sort tool from 10 works well.
0 Kudos
KimOllivier
Occasional Contributor III
There is a better way to sort points for labelling. The technique uses a Peano curve to sort the points into a snakes and ladders type of route where the next number is always near the last. This is similar to the way that we used to number labels on polygons when we used to digitise by hand!

The Peano Curve is an option on the ArcGIS 10 sort (data management) tool. It basically comes up with a single index for the x,y pairs that is a very useful figure to sort a point cloud so that you can easily find any point if they are sequentially numbered.