You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - Geoprocessing ArcToolbox forum

Spatial Join in ModelBuilder   sirisha polsapalli Aug 01, 2006
Re: Spatial Join in ModelBuilder   Dan Patterson Aug 01, 2006
Re: Spatial Join in ModelBuilder   sirisha polsapalli Aug 01, 2006
Re: Spatial Join in ModelBuilder   Chris Woodward Feb 05, 2007
Re: Spatial Join in ModelBuilder   sirisha polsapalli Feb 05, 2007
Re: Spatial Join in ModelBuilder   Wendy Rolston Jan 24, 2008
Re: Spatial Join in ModelBuilder   Adam Cabrera Apr 24, 2007
Re: Spatial Join in ModelBuilder   Danny Wijnberg Apr 26, 2007
Re: Spatial Join in ModelBuilder   Jan Benson Jul 16, 2007
Re: Spatial Join in ModelBuilder   Adam Cabrera Jul 26, 2007
Re: Spatial Join in ModelBuilder   Jan Benson Jul 26, 2007
Re: Spatial Join in ModelBuilder   Jaap boheemen Oct 18, 2007
Re: Spatial Join in ModelBuilder   Kai Goede Feb 12, 2009
Re: Spatial Join in ModelBuilder   Mike Bowser Apr 17, 2008
Re: Spatial Join in ModelBuilder   David Hollema Sep 08, 2008
Re: Spatial Join in ModelBuilder   Cheryl Bosley Nov 21, 2008
Re: Spatial Join in ModelBuilder   Ellen Kersten Dec 03, 2008
Re: Spatial Join in ModelBuilder   Adam Cabrera Dec 03, 2008
Re: Spatial Join in ModelBuilder   Ellen Kersten Dec 09, 2008
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Spatial Join in ModelBuilder 
Author sirisha polsapalli 
Date Aug 01, 2006 
Message Hello:
How can I perform a Spatial Join in ModelBuilder? I am trying to join points to polygons.
Can anyone help?
Thanks in advance.
Sirisha. 
  Isha
GIS Analyst

 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Dan Patterson 
Date Aug 01, 2006 
Message did you see
http://forums.esri.com/Thread.asp?c=93&f=1728&t=137414&mc=8
http://forums.esri.com/Thread.asp?c=93&f=1729&t=150643&mc=2#439123 
  Geomatics, Carleton University, Ottawa, Canada 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author sirisha polsapalli 
Date Aug 01, 2006 
Message Hello:
Thank you for your response. I used the model present at
http://forums.esri.com/Thread.asp?c=93&f=1728&t=137414&mc=8
I am trying to create Points to Polygon Spatial join.
But if I use the Identify tool from the ArcToolBox it only identifies points inside the polygon.And then did the Add join. I am not getting the attribute table same as if I do it directly using 'Joins and Relates" on ArcMap

After the obtaining the polygon through spatial join I need to query on that. But the fields which I should be obtaining by Spatially joining Points to Polygon are missing. A new field called "distance' should be created after the spatial join but it is missing.
Is there a better solution?
Thanks in advance.
Sirisha. 
  Isha
GIS Analyst

 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Chris Woodward 
Date Feb 05, 2007 
Message I too am having similar problems. I am attempint to perform a Spatial Join in ArcGIS 9.2 Desktop (ArcInfo) using modelbuilder and am having the same difficulty where the fields I choose to be in the output varialbe are not present after the spatial join is complete. The varialbe I want to be included (ID) is added and calculated just before the Spatial Join is run - I'm not sure if that matters. If I manually re-set up the Spatial Join parameters from editing the model, Spatial Join runs fine with the ID field joined and populated. If I just run from the model>Open, the ID field is dropped. I think it may be a bug. Any help would be greatly appreciated. Thanks,
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author sirisha polsapalli 
Date Feb 05, 2007 
Message Sorry, but I could not find a solution to that. It might be a bug. 
  Isha
GIS Analyst

 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Wendy Rolston 
Date Jan 24, 2008 
Message I am trying to run the spatial join tool inside a model, but the long integer field that needs to be 'transferred' over to the target shapefile comes up blank. Has anyone had this happen or have any idea how to make it work. If I do a spatial join the old fashioned way in the TOC it works but I need to do hundreds of shapefiles. A model would be nice.

Thanks
Wendy
ArcView 9.2 post SP3 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Adam Cabrera 
Date Apr 24, 2007 
Message It is indeed a bug. The tool works fine if the 2 items being joined already exist, but if 1 or both are derived data, your output will not contained those fields. The following script resolves this issue.

If you would prefer, I can post a toolbox that has the script configured as a tool.

Hope this helps.

Adam 
 
# ---------------------------------------------------------------------------
# SpatialJoin.py
# Created on: Tuesday April 24 2007 
#   By: Adam Cabrera, King County DDES (adam.cabrera@metrokc.gov)
# Description: The existing spatial join in 9.2 works fine for data that
#   exists at the time of execution, but does not recognize fields that are from
#   derived data.  This script resolves this issue by mapping the fields and applying
#   them at the time of the spatial join.
# Use as a tool:
#   Arg1 - Data Type: Feature Layer, Direction: Input
#   Arg2 - Data Type: Feature Layer, Direction: Input
#   Arg3 - Data Type: Feature Class, Direction: Output
# ---------------------------------------------------------------------------

# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

# Inputs
targetFeatures = sys.argv[1]
joinFeatures = sys.argv[2]

# Output
outfc = sys.argv[3]

# Create a new fieldmappings and add the two input feature classes.
fieldmappings = gp.CreateObject("FieldMappings")
fieldmappings.AddTable(targetFeatures)
fieldmappings.AddTable(joinFeatures)

#Run the Spatial Join tool, using the defaults for the join operation and join type
outfc = gp.SpatialJoin(targetFeatures, joinFeatures, outfc, "#", "#", fieldmappings)

 
  SpatialJoin_script.zip (opens in new window)
 
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Danny Wijnberg 
Date Apr 26, 2007 
Message He Adam,
I have the same problems with my spatial join, but for me it would be nice if you could attach the tool, because I don't no what to do with the python file. thx 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Jan Benson 
Date Jul 16, 2007 
Message Adam,

Did you ever get around to posting the spatial join script as a tool that can be added to the toolbox?

Thanks! 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Adam Cabrera 
Date Jul 26, 2007 
Message Thanks for the reminder:

I've attached a zip file that contains the toolbox and a subdirectory (scripts) that contains the python script. The toolbox refers to the script with a relative path, so as long as the scripts directory in the same folder as the toolbox, it should work fine.

Adam 
  Adam_SJ_Toolbox.zip (opens in new window)
 
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Jan Benson 
Date Jul 26, 2007 
Message Thanks for putting it in a toolbox form! It really helps those of use starting to use model builder and python. 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Jaap boheemen 
Date Oct 18, 2007 
Message Hello Adam,
Thanx for the great tool. This one is more reliable in writing the data in the output FC.

Is there a possibillity to adjust the fields and their field contents in your script/toolbox?
I need to get the minimum values in the output FC.

Many thanks in advance!!! 
  Jaap 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Kai Goede 
Date Feb 12, 2009 
Message Hi,

The tool worked fine in ArcGIS 9.2. Now, after I installed version 9.3 I receive an error message:

: Object: Tool or environment not found
Failed to execute (SpatialJoin).

Can anyone help?

Thanks

Kai 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Mike Bowser 
Date Apr 17, 2008 
Message I am having the same issue. has this been reported as a bug to ESRI? I am using sp 5 and still have this bug. 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author David Hollema 
Date Sep 08, 2008 
Message I just reported this bug today on 9.2 SP3. ESRI confirmed the bug. The workaround works great, thanks Adam.

Dave 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Cheryl Bosley 
Date Nov 21, 2008 
Message Adam, your script worked great. However a few of my point features are located out of the polygon area. Is there anyway to add a closest to or distance value to get the values for them? Thanks. 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Ellen Kersten 
Date Dec 03, 2008 
Message I have this question too. For example, if there is no point inside a polygon, how can I create a parameter to provide an output of the value for the closest point?
thanks,
Ellen
9.3
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Adam Cabrera 
Date Dec 03, 2008 
Message There are some new options in 9.3 that deal with closest that were not available in previous versions. Would it be helpful for me to expose them?

-Adam 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Spatial Join in ModelBuilder 
Author Ellen Kersten 
Date Dec 09, 2008 
Message yes, please!