In-memory join does not return One-To-Many

1114
9
06-26-2020 07:53 AM
FrédéricSCHETTINI
New Contributor II

Hi,

I am trying to join an in-memory Feature Class and an in-memory Table.

I get only one row of the FC joins to one row of the table where the input and output join fields match

It seems that is One-To-Many Join.

Performing the same join with the Feature Class and Table in the GDB, I get the expected resul meaning One-To-Many Join.

I have tested both using arcpy and ArcGIS Pro.

Is there a way to have the join using memory workspace returns an One-To-Many join?

Thank you

Frédéric.

0 Kudos
9 Replies
NobbirAhmed
Esri Regular Contributor

Are you using Add Join tool? 

JoeBorgione
MVP Emeritus

How do you create a one to many join?

That should just about do it....
0 Kudos
NobbirAhmed
Esri Regular Contributor

If you are in Geoprocessing world then you have to use Spatial Join for one-to-many option. Add Join doesn't have that option.

GDB .Net SDK might have this option to get it done using PRo SDK - but I'm not knowledgeable of GDB SDK. I'll try to find out.

0 Kudos
JoeBorgione
MVP Emeritus

Okay; that's what I thought but when you asked the OP if he was using the Add Join tool I thought to myself 'Have I been living under a rock and missed this?'

That should just about do it....
DavidPike
MVP Frequent Contributor

Can you persist it in a scratch workspace?

0 Kudos
NobbirAhmed
Esri Regular Contributor

If the layer to which records are joined is a Feature Class then you can persist by using Copy Features (management) tool - if it is a Table then you can use Copy (management) tool.

You can save to scratch workspace if you set one in Analysis environment:

0 Kudos
FrédéricSCHETTINI
New Contributor II

Here the tests I have done

# TEST 1:  ADD JOIN USING MEMORY FC AND TABLE 
#COPY TABLE IN MEMORY
arcpy.conversion.TableToTable("HERE_DA_Bardonechia_A32_SS335_Vittoria", "memory", "HERE_DA_Bardonechia_A32_SS335_VittoriaMemory", .........)

#COPY FC IN MEMORY
arcpy.conversion.FeatureClassToFeatureClass(r"A32BardonnexOulx\StreetsA32BardonecchiaOulx", "memory", "StreetsA32BardonecchiaOulxMemory", .......)

#ADD JOIN BETWEEN MEMORY FC AND MEMORY TABLE
arcpy.management.AddJoin("StreetsA32BardonecchiaOulxMemory", "LINK_DIR_FROM", "HERE_DA_Bardonechia_A32_SS335_VittoriaMemory", "LINK_DIR", "KEEP_COMMON")

# => 37 records joined in StreetsA32BardonecchiaOulxMemory


# TEST 2: ADD JOIN USING GDB FC AND TABLE
arcpy.management.AddJoin(r"A32BardonnexOulx\StreetsA32BardonecchiaOulx", "LINK_DIR_TO", "HERE_DA_Bardonechia_A32_SS335_Vittoria", "LINK_DIR", "KEEP_COMMON")

# => 4 536 records joined in StreetsA32BardonecchiaOulx (expected result)

I get only 37 rows joined (each feature is joined only once) if I used memory FC and table.

Thanks for your help.

0 Kudos
NobbirAhmed
Esri Regular Contributor

Hi Frédéric SCHETTINI , could you please share your data? I would like to test. You don't need to share the whole dataset - remove fields that I don't need for testing. 

Thanks, Nobbir (GP SDK Team)

0 Kudos
NobbirAhmed
Esri Regular Contributor

My email is: nahmed@esri.com

0 Kudos