POST
|
I'm reformatting this question as it seems I didn't do it right when I asked first time round. here is my problem. if I run a one to many spatial analysis between a polygon and point feature class using arcmap, the result gives me the upper number of what I need (459 results), where as if I attempt to do it through arcpy, I get the lower number, as the one to many doesn't work (55 results) I've tried everything I can think of, and I need this to work through arcpy as I'm doing it as a tool for another team where the guys using it has very poor understanding of arcmap and so do his team. below is the code I use. I have also attached the same code from exporting the arcmap function as code. so for the first code you see is the python snippet of what I have done in arcmap. I display XY data of a dbf table and do the below arcpy.SpatialJoin_analysis(target_features="templayer", join_features="temptab Events", out_feature_class="H:/ArcGIS/Default.gdb/templayer_SpatialJoin12", join_operation="JOIN_ONE_TO_MANY", join_type="KEEP_ALL", field_mapping=(long string of code for the field attributes), match_option="INTERSECT", search_radius="", distance_field_name="") the above gives me what I want whereas my code below; import arcpy, csv, openpyxl, os, xlrd, datetime
from arcpy import env
env.workspace = r"C:\Users\myname\Desktop\Yanko's tool"
arcpy.env.overwriteOutput = True
gdb = r"C:\Users\ronan.corrigan\Desktop\Yanko's tool\Yankos.gdb"
today = datetime.datetime.today().strftime('%y%m%d')
temptab = r"C:\Users\ronan.corrigan\Desktop\Yanko's tool\Yankos.gdb\temptab"
arcpy.MakeXYEventLayer_management(temptab, "XCoord", "YCoord", "{}\templayer2".format(gdb)) r
esult2 = "{}\templayer2".format(gdb)
layer = r"C:\Users\ronan.corrigan\Desktop\Yanko's tool\Yanko's Duplicate tool\Example_Polygons.shp"
arcpy.FeatureClassToFeatureClass_conversion(layer, gdb, "templayer")
result = r"C:\Users\ronan.corrigan\Desktop\Yanko's tool\Yankos.gdb\templayer"
arcpy.SpatialJoin_analysis(result, result2, r"{}\YankosTool {}".format(gdb, today), "JOIN_ONE_TO_MANY", "KEEP_ALL") doesn't give me the full 459 (I copy and paste out the result1 because its a reference layer I need for all of them, the above is a slightly simplified version, but rest assured that the input to arcmap that is "temptab" is exactly the same as the make xy event layer "result 2" in my code and both the temp layers are the same). I tried copying and pasting the first block and changing the parameters to match what's needed, but I still only get the 55. like below arcpy.SpatialJoin_analysis(input1, input2, out_feature_class="C:/Users/ronan.corrigan/Desktop/Yanko's tool/Yankos.gdb/testing2", join_operation="JOIN_ONE_TO_MANY", join_type="KEEP_ALL", field_mapping= long string of code for the field attributes)', match_option="INTERSECT", search_radius="", distance_field_name="") where input 1 and input 2 are just the inputs ive referenced as result 1 and result 2 before. but again I just keep getting 55 instead of the 459, which doing it through arcmap gives me. if I try doing it so that result 1 and result 2 are switched I just end up with points, buts it's polygons I need can anyone see what's going wrong here, or maybe encountered this issue before?
... View more
04-08-2019
04:17 AM
|
0
|
0
|
429
|
POST
|
I'm currently creating an arcpy tool for another team, and the final step is to run a spatial join analysis. the input polygon layer has 55 results, while the input point layer has over 400 currently, but this can go up and down, but never below the 55. the only issue is when I run the analysis, I only get 55 polygons coming out the other end. the weird thing about this is, if I do the whole process in arcmap I get the full 400+polygons with the right data. even simply just copying and pasting the python snippet of the correct results, and adjusting the inputs so they are formatted correctly doesn't seem to work. has anyone encountered anything like this before? where arcpy seems limited compared to arcmap? it just seems bizzare to me that running the exact same process, copy and pasted, between arcmap and arcpy gives different results like that
... View more
04-05-2019
08:46 AM
|
0
|
1
|
328
|
POST
|
I have been using double quotes the whole time but I still get an error below is an example fo what i'm doing; arcpy.CopyRows_management(excelscript, r"{}\Testsheet.csv".format(location)) pfc_temp = r"{}\Testsheet.csv".format(location) where location is a folder parameter. if I just set location to the folder in question directly it still comes up with the same error
... View more
02-11-2019
01:04 AM
|
0
|
2
|
2649
|
POST
|
I'm trying to create an arcpy tool for one of the teams, and I have everything working. But when I redirect the path names to be where their data is saved and where they want the outputs to go to, I get errors like ERROR:00732 or ERROR:00210 and its because of the folder directories having spaces in their names. is there a work around for this? as getting the team to rename all their folders to exclude spaces isn't an easy sell thanks lads and lasses
... View more
02-08-2019
08:32 AM
|
0
|
7
|
3885
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|