Hi, I'm writing a script that is part 2 of a bigger automation process. Part 1 was written by someone else (who, of course, doesn't work at the company anymore) and works perfectly.
My script piggy backs on features created in part 1 and I'm getting 2 errors:
Traceback <SPAN class="punctuation token">(</SPAN>most recent call last<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">:</SPAN>
File <SPAN class="string token">"Y:\BI\Alicia\Scripts\ShrinkModel_3_0_SingleSite_2016Data.py"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">46</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> <SPAN class="operator token"><</SPAN>module<SPAN class="operator token">></SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SpatialOverlay_ba<SPAN class="punctuation token">(</SPAN>inputLayer<SPAN class="punctuation token">,</SPAN> inputSimpleRing<SPAN class="punctuation token">,</SPAN> ShrDemoFields<SPAN class="punctuation token">,</SPAN> ShrSimpleRing<SPAN class="punctuation token">)</SPAN>
File <SPAN class="string token">"C:\Program Files (x86)\ArcGIS\Desktop10.4\Business Analyst\ArcToolbox\Toolboxes\Business Analyst Tools.tbx"</SPAN><SPAN class="punctuation token">,</SPAN> line <SPAN class="number token">483</SPAN><SPAN class="punctuation token">,</SPAN> <SPAN class="keyword token">in</SPAN> SpatialOverlay
ExecuteError<SPAN class="punctuation token">:</SPAN> ERROR <SPAN class="number token">000622</SPAN><SPAN class="punctuation token">:</SPAN> Failed to execute <SPAN class="punctuation token">(</SPAN>SpatialOverlay<SPAN class="punctuation token">)</SPAN><SPAN class="punctuation token">.</SPAN> Parameters are <SPAN class="operator token">not</SPAN> valid<SPAN class="punctuation token">.</SPAN>
ERROR <SPAN class="number token">000800</SPAN><SPAN class="punctuation token">:</SPAN> The value <SPAN class="keyword token">is</SPAN> <SPAN class="operator token">not</SPAN> a member of TOTPOP_CY <SPAN class="operator token">|</SPAN> HHPOP_CY <SPAN class="operator token">|</SPAN> FAMPOP_CY <SPAN class="operator token">|</SPAN> GQPOP_CY <SPAN class="operator token">|</SPAN> POPDENS_CY <SPAN class="operator token">|</SPAN> TOTHH_CY <SPAN class="operator token">|</SPAN> AVGHHSZ_CY <SPAN class="operator token">|</SPAN> FAMHH_CY <SPAN class="operator token">|</SPAN> AVGFMSZ_CY <SPAN class="operator token">|</SPAN> TOTHU_CY <SPAN class="operator token">|</SPAN> OWNER_CY <SPAN class="operator token">|</SPAN> RENTER_CY <SPAN class="operator token">|</SPAN> VACANT_CY <SPAN class="operator token">|</SPAN> POPGRW10CY <SPAN class="operator token">|</SPAN> HHGRW10CY <SPAN class="operator token">|</SPAN> FAMGRW10CY <SPAN class="operator token">|</SPAN> POP0_CY <SPAN class="operator token">|</SPAN> POP5_CY <SPAN class="operator token">|</SPAN> POP10_CY <SPAN class="operator token">|</SPAN> POP15_CY <SPAN class="operator token">|</SPAN> POP20_CY <SPAN class="operator token">|</SPAN> POP25_CY <SPAN class="operator token">|</SPAN> POP30_CY <SPAN class="operator token">|</SPAN> POP35_CY <SPAN class="operator token">|</SPAN> POP40_CY <SPAN class="operator token">|</SPAN> POP45_CY <SPAN class="operator token">|</SPAN> POP50_CY <SPAN class="operator token">|</SPAN> POP55_CY <SPAN class="operator token">|</SPAN> POP60_CY <SPAN class="operator token">|</SPAN> POP65_CY <SPAN class="operator token">|</SPAN> POP70_CY <SPAN class="operator token">|</SPAN> POP75_CY <SPAN class="operator token">|</SPAN> POP80_CY <SPAN class="operator token">|</SPAN> POP85_CY <SPAN class="operator token">|</SPAN> POP18UP_CY <SPAN class="operator token">|</SPAN> POP21UP_CY <SPAN class="operator token">|</SPAN> MEDAGE_CY <SPAN class="operator token">|</SPAN> <SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>
I already checked my parameters and the only thing I didn't add were the last two optional parameters.
SpatialOverlay_ba (InputFeatureLayer, OverlayLayer, SelectedSummarizations, OutputFeatureClass,
{SpatialOverlayAppendData}, {UseSelectedFeatures})
For the 2nd error, I already checked the spelling of all 27 fields that I'm asking the overlay to get. I misspelled A55NW150CY originally as _CY. The data is the 2016 U.S. Data for BA extension.
Any ideas on how to solve this conundrum?
Thanks and Happy New Year!!!
<SPAN class="comment token"># Import arcview and arcpy library</SPAN>
<SPAN class="keyword token">import</SPAN> arcview
<SPAN class="keyword token">import</SPAN> arcpy
<SPAN class="comment token"># Overwrite any previous output</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>overwriteOutput <SPAN class="operator token">=</SPAN> <SPAN class="token boolean">True</SPAN>
<SPAN class="comment token"># Set workspace from the selection in tool menu</SPAN>
<SPAN class="comment token">####myWorkspace = arcpy.GetParameterAsText(0)</SPAN>
<SPAN class="comment token">####arcpy.env.workspace = myWorkspace</SPAN>
myWorkspace <SPAN class="operator token">=</SPAN> <SPAN class="string token">"X:\Users\Alicia.Shyu\TestingScript\ScriptTest"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>env<SPAN class="punctuation token">.</SPAN>workspace <SPAN class="operator token">=</SPAN> myWorkspace
<SPAN class="keyword token">print</SPAN> myWorkspace
<SPAN class="comment token"># Check out extensions for Business and Network Analyst</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CheckOutExtension<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Business"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CheckOutExtension<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Network"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Business Analyst and Network Analyst extensions available"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Set spatial reference; 4269 is code for GCS_North_American_1983</SPAN>
spatialRef <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>SpatialReference<SPAN class="punctuation token">(</SPAN><SPAN class="number token">4269</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Spatial reference set"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Add Business Analyst toolbox to script</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>AddToolbox<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"C:\Program Files (x86)\ArcGIS\Desktop10.4\Business Analyst\ArcToolbox\Toolboxes\Business Analyst Tools.tbx"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Business Analyst toolbox added"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Set simple ring feature class from selection in tool menu</SPAN>
<SPAN class="comment token"># Simple ring were created during internal model script</SPAN>
inputRing <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">1</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Create variables for spatial overlay function</SPAN>
inputLayer <SPAN class="operator token">=</SPAN> <SPAN class="string token">"C:\ArcGIS\Business Analyst\US_2016\Data\Demographic Data\esri_bg.bds"</SPAN>
ShrDemoFields <SPAN class="operator token">=</SPAN> "POPDENS_CY<SPAN class="punctuation token">;</SPAN> INDCONS_CY<SPAN class="punctuation token">;</SPAN> INDRTTR_CY<SPAN class="punctuation token">;</SPAN> OCCSSRV_CY<SPAN class="punctuation token">;</SPAN> OCCHLTH_CY<SPAN class="punctuation token">;</SPAN> OCCPERS_CY<SPAN class="punctuation token">;</SPAN> OCCCONS_CY<SPAN class="punctuation token">;</SPAN> \
DIVORCD_CY<SPAN class="punctuation token">;</SPAN> A45I15_CY<SPAN class="punctuation token">;</SPAN> A55I0_CY<SPAN class="punctuation token">;</SPAN> A55I50_CY<SPAN class="punctuation token">;</SPAN> A25DI15_CY<SPAN class="punctuation token">;</SPAN> A55NW15_CY<SPAN class="punctuation token">;</SPAN> A55NW50_CY<SPAN class="punctuation token">;</SPAN> \
A55NW150CY<SPAN class="punctuation token">;</SPAN> A65NW35_CY<SPAN class="punctuation token">;</SPAN> A75NW15_CY<SPAN class="punctuation token">;</SPAN> AGGNWA75CY<SPAN class="punctuation token">;</SPAN> RURALHU10<SPAN class="punctuation token">;</SPAN> RNT3PERS10<SPAN class="punctuation token">;</SPAN> OOHHR75C10<SPAN class="punctuation token">;</SPAN> \
VACRENT10<SPAN class="punctuation token">;</SPAN> VACRNTED10<SPAN class="punctuation token">;</SPAN> VACSOLD10<SPAN class="punctuation token">;</SPAN> VACOTHER10<SPAN class="punctuation token">;</SPAN> VACRNTED100<SPAN class="punctuation token">;</SPAN> VACSOLD100"
<SPAN class="comment token"># Append shrink model data to simple ring feature class</SPAN>
ShrRing <SPAN class="operator token">=</SPAN> <SPAN class="string token">"ShrinkSimpleRingAppend"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SpatialOverlay_ba<SPAN class="punctuation token">(</SPAN>inputLayer<SPAN class="punctuation token">,</SPAN> inputRing<SPAN class="punctuation token">,</SPAN> ShrDemoFields<SPAN class="punctuation token">,</SPAN> ShrRing<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Shrink Simple Ring Append Done"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Set drive time feature class from selection in tool menu</SPAN>
<SPAN class="comment token"># Drive time were created during internal model script</SPAN>
inputDriveTime <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">2</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Append shrink model data to drive time feature class</SPAN>
ShrDriveTime <SPAN class="operator token">=</SPAN> <SPAN class="string token">"ShrinkDriveTimeAppend"</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>SpatialOverlay_ba<SPAN class="punctuation token">(</SPAN>inputLayer<SPAN class="punctuation token">,</SPAN> inputDriveTime<SPAN class="punctuation token">,</SPAN> ShrDemoFields<SPAN class="punctuation token">,</SPAN> ShrDriveTime<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Shrink Drive Time Append Done"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Set new workspace as output for Excel file</SPAN>
myWorkspaceTable <SPAN class="operator token">=</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>GetParameterAsText<SPAN class="punctuation token">(</SPAN><SPAN class="number token">3</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Export shrink simple ring data to Excel</SPAN>
excelExtension <SPAN class="operator token">=</SPAN> <SPAN class="string token">".xls"</SPAN>
ShrSimpRStr <SPAN class="operator token">=</SPAN> <SPAN class="string token">"ShrinkSimpRTable"</SPAN>
ShrSimpRTable <SPAN class="operator token">=</SPAN> myWorkspaceTable <SPAN class="operator token">+</SPAN> <SPAN class="string token">"/"</SPAN> <SPAN class="operator token">+</SPAN> ShrSimpRStr <SPAN class="operator token">+</SPAN> excelExtension
arcpy<SPAN class="punctuation token">.</SPAN>TableToExcel_conversion<SPAN class="punctuation token">(</SPAN>ShrSimpleRing<SPAN class="punctuation token">,</SPAN> ShrSimpRTable<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Shrink Simple Ring Table Done"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Export shrink drive time data to Excel</SPAN>
excelExtension <SPAN class="operator token">=</SPAN> <SPAN class="string token">".xls"</SPAN>
ShrinkDrivTStr <SPAN class="operator token">=</SPAN> <SPAN class="string token">"ShrinkDrivTTable"</SPAN>
ShrinkDrivTTable <SPAN class="operator token">=</SPAN> myWorkspaceTable <SPAN class="operator token">+</SPAN> <SPAN class="string token">"/"</SPAN> <SPAN class="operator token">+</SPAN> ShrinkDrivTStr <SPAN class="operator token">+</SPAN> excelExtension
arcpy<SPAN class="punctuation token">.</SPAN>TableToExcel_conversion<SPAN class="punctuation token">(</SPAN>ShrinkDriveTime<SPAN class="punctuation token">,</SPAN> ShrinkDrivTTable<SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Shrink Drive Time Table Done"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="comment token"># Return Business Analyst and Network Analyst extensions</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CheckInExtension<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Business"</SPAN><SPAN class="punctuation token">)</SPAN>
arcpy<SPAN class="punctuation token">.</SPAN>CheckInExtension<SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Network"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Business Analyst and Network Analyst extensions returned"</SPAN><SPAN class="punctuation token">)</SPAN>
<SPAN class="keyword token">print</SPAN> <SPAN class="punctuation token">(</SPAN><SPAN class="string token">"Done"</SPAN><SPAN class="punctuation token">)</SPAN><SPAN class="line-numbers-rows"><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN><SPAN></SPAN></SPAN>