+ Reply to Thread
Results 1 to 10 of 10

Thread: Linear attribute data isolation for join with polygons

  1. #1
    Hailey Monod
    Join Date
    May 2012
    Posts
    24
    Points
    0
    Answers Provided
    3


    0

    Question Linear attribute data isolation for join with polygons

    Hello ,

    I have some polygons representative of roadway sections and I have some line data representative of roadway condition and classification. I am looking for a way to join attributes from the line data to the polygon data, however at times there are multiple line segments within a polygon- each with different attributes - and I would like to join only the attributes (condition and classification attributes) of the longest line segment that falls within each polygon.

    I have tried many functions of the spatial join, but when I choose the merge rule “maximum” on the shape length field of the line data it does not seem to bring the associated attributes??! (Only the longest shape lengths are joined, and the other two attribute fields seem random, or are joined based on their merge rule not that of the shape length field) I have tried spatial joins and then just regular table joins and I have tried intersection tools…. No luck yet on getting the correct information.

    If anybody has any ideas on this please let me know,

    Thanks in advance
    Hailey

  2. #2
    Nobbir Ahmed

    Join Date
    Jun 2010
    Posts
    327
    Points
    124
    Answers Provided
    17


    0

    Default Re: Linear attribute data isolation for join with polygons

    As an if-then condition has to be met, I'm afraid you cannot do it through tool dialog.

    Most probably you'll need to write a python script manipulating the fieldmap object based on the if condition. Which version of ArcGIS you are using?

    For 9.3 and 9.3.1 the help link is:
    http://webhelp.esri.com/arcgisdeskto...ngs_properties

    For 10.0:
    Fieldmap object: http://help.arcgis.com/en/arcgisdesk...0000081000000/
    Fieldmappings object: http://help.arcgis.com/en/arcgisdesk...000008q000000/

  3. #3
    Hailey Monod
    Join Date
    May 2012
    Posts
    24
    Points
    0
    Answers Provided
    3


    0

    Default Re: Linear attribute data isolation for join with polygons

    Oh dear! I am using v10, but I havent done anything like that yet, so I better start reading....
    Thanks for your advice

  4. #4
    Nobbir Ahmed

    Join Date
    Jun 2010
    Posts
    327
    Points
    124
    Answers Provided
    17


    0

    Default Re: Linear attribute data isolation for join with polygons

    Here is a non-scriptin way. You can create a Model in ModelBuilder by chaining the processes.

    To learn about how to use the Field Mapping control review this topic:
    http://help.arcgis.com/en/arcgisdesk...0000000s000000


    Target features: sections (polygons)
    Join features: roads (lines)

    Step 1:
    Add a field (type double) named Length to the roads feature class to store the shape length values.

    Step 2:
    Right-click on the newly added field and select Field Calculator ... select Shape_Length from the Fields group. Hit Ok.

    Step 3:
    Run spatial join - in the tool dialog set parameter values as follows:

    Target: sections
    Join: roads
    JOIN_ONE_TO_ONE
    Chose match option of your interest (say, CONTAINS)
    Output feature class: spj_1

    In the fieldmap, delete all shape-related fields (Shape_area, shape_length etc). Add a new output field of type Double and name it ShpLength. Set a merge rule of Maximum. Right-click on ShpLength and select Add Input Field. Select roads.Length field from the available fields.

    Run the tool

    Step 4:
    Re-run spatial join by double-clicking on the result node (Results window). Give a different name to the output and change only these parameter values:

    JOIN_ONE_TO_MANY
    Change the ShpLenght fieldmap's merge rule to First.
    Output feature class: spj_2 (must be different from the first output)

    Run the tool.

    Step 5:
    Run Join Field tool as follows:

    Input table: spj_1
    Input Join Field: ShpLength
    Join Table: spj_2
    Output Join Field: ShpLength
    Join Fields: JOIN_FID

    Step 6:
    Run Join Field again. This time use parameter values as follows:

    Input Table: spj_1
    Input Join Field: JOIN_FID
    Join Table: roads
    Output Join Field: OBJECTID (or whatever the name of the OID field)

    Join Fields: Condition and Classification

  5. #5
    Hailey Monod
    Join Date
    May 2012
    Posts
    24
    Points
    0
    Answers Provided
    3


    0

    Default Re: Linear attribute data isolation for join with polygons

    Wow! That worked well for me, THANK YOU SO MUCH!!!
    Really appreciate your help

  6. #6
    Hailey Monod
    Join Date
    May 2012
    Posts
    24
    Points
    0
    Answers Provided
    3


    0

    Arrow Re: Linear attribute data isolation for join with polygons

    Hello NobbirAhmed,

    As you were so knowledgeable on my previous question, I was just wondering if you happen to know anything about changing the field mapping rules slightly? I noticed that the mode rule will choose the highest numeric value when there is a tie, however is there anyway for me to change it, or use a combination of rules to say "choose the mode (most frequent occuring value) and if there is a tie then choose the lowest numeric value" ...
    Please let me know if you have any insight?!

    Thank you!!!
    Hailey

  7. #7
    Nobbir Ahmed

    Join Date
    Jun 2010
    Posts
    327
    Points
    124
    Answers Provided
    17


    0

    Default Re: Linear attribute data isolation for join with polygons

    Quote Originally Posted by monodh View Post
    I noticed that the mode rule will choose the highest numeric value when there is a tie
    I think it is the opposite. I've just tested. I have 3 mode values (2, 3, 7) with equal frienquencies (14). When I set Mode as merge rule - the output gets 2 (the lowest value). Which version of ArcGIS you are using?

    Quote Originally Posted by monodh View Post
    .. use a combination of rules to say "choose the mode (most frequent occuring value) and if there is a tie then choose the lowest numeric value" ...
    I guess we are out of luck this time (unless someone comes up with a good answer). We need to use Python to get things done. I'll get back if I can find a good solution.

  8. #8
    Hailey Monod
    Join Date
    May 2012
    Posts
    24
    Points
    0
    Answers Provided
    3


    0

    Default Re: Linear attribute data isolation for join with polygons

    Oh, I think your right, this is what the help page says:

    "•Mode—Use the value with the highest frequency (most common). If there is more than one value with the highest frequency (i.e., a tie), then the list of Mode values will be sorted (smallest first for numeric, alphabetical for text), and the first one will be used."

    So in that case, I was mixed up, I actually need a rule that looks at all the values and first chooses the value that repeats itself the most, and if that is not possible then it chooses the highest value. So for your example, it would choose 7 (from 2,3,7)

    Hhmmm, let me know if you think of a work around?!

    Thanks again for alll your help

  9. #9
    Nobbir Ahmed

    Join Date
    Jun 2010
    Posts
    327
    Points
    124
    Answers Provided
    17


    0

    Default Re: Linear attribute data isolation for join with polygons

    I have a workaround in Python but we need to test it to make sure it works. Email me nahmed@esri.com and I'll send you instructions so that you can try with your data. If the solution is workable we'll then upload the script/instructions to this thread.

  10. #10
    Hailey Monod
    Join Date
    May 2012
    Posts
    24
    Points
    0
    Answers Provided
    3


    0
    This post is marked as the answer

    Default Re: Linear attribute data isolation for join with polygons

    Hi Nobbir,

    Thank you so much! The python script did the trick!
    I have attached the zip file for others to use

    For users: make sure you first run a spatial join with the one-to-one option, and construct one field map with the mode merge rule, and then re-run the spatial join, but only change the option for the one-to-many and its output name. Afterwards, connect to the script tool, and use the first spatial join in the fist parameter and the second spatial join in the second parameter and then in the third parameter use the field you used with the mode merge rule. And it will update the first spatial join feature class.

    Thanks again!
    Hailey
    Attached Files

+ Reply to Thread

Tags for this 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