I need to find angles of streets where they intersect with roadways covering the entire state. Does anyone have a method and/or tools in mind?
Solved! Go to Solution.
Put the below at the top of the script
import arcpy
Wes,
I mentioned in my comment that I tried that and it fixed the first error. However, the second error came up afterwords. I tried changing the paths from 'in_memory' to a file geodatabase and it gave me the same error. I looked through the script provided by ArcGIS for Intersect in the location provided in the error, and I didn't see any syntax issues (obviously, why would there be if it worked for Darren and others...)
I see where in line 289 it gives me an error, but I'm not sure why. Here is what the script says:
from arcpy.geoprocessing._base import gp, gp_fixargs
from arcpy.arcobjects.arcobjectconversion import convertArcObjectToPythonObject
try:
retval = convertArcObjectToPythonObject(gp.SpatialJoin_analysis(*gp_fixargs((target_features, join_features, out_feature_class, join_operation, join_type, field_mapping, match_option, search_radius, distance_field_name), True)))
return retval
except Exception, e:
raise e
I'm trying to figure out why it raised e. I am only using a single polyline feature class to perform this analysis, but I didn't see that as an issue with the Intersect tool. I made sure to replace my lines to the path to the file geodatabase (although I have a feeling it may need to be a shapefile to access the .dbf file???)
Maybe we'll see something if you post the script up to the point where it throws the error.
Darren - you're absolutely right. I should have post that. Apologies. Here it is:
import arcpy
import os
fc = "C:\Users\jmullins\Desktop\GIS Data\Customer Data\Washington County FL\Washington County FL Data\WashingtonCountyFL.gdb\GEO\StreetCenterline"
sr = arcpy.Describe(fc).spatialReference
radius = 50
out_fc = r'in_memory\points'
int_pt = r'in_memory\int_pt'
arcpy.Intersect_analysis(fc,int_pt,output_type='POINT')
fc = r"c: etc
I didn't get past there
Thanks so much to everybody for all your help. I was able to make it work! It was two things:
1. Dan - you were absolutely spot-on with the file path. I moved the geodatabase up and made it work. For this tool, I may simply export to a shapefile in a higher-level folder and then reimport back into the original geodatabase. Or I may just have to reorganize all my data, which is probably a good thing considering the issues here.
2. Since this wasn't a shapefile and was a feature class, I made sure to change any tool looking for 'FID' to look for 'OBJECTID', and it worked like a charm. Thanks so much for all the help.
One last question: is there a way to iterate this so that it overwrites files with the same name? I want this to become automated so that a customer could run this script (as part of a much larger model) on a regular basis whenever they want without having to concern themselves with errors about how a shapefile or feature class already exists. If not, I'm sure I can put a 'Delete' option in the model to delete the files afterwards.
Thanks again.
Thanks Wes - makes sense. Where would I put this line of code? After every instance where an arcpy method is called?
use OIDFieldname all the time, applies to tables as well...saves the hastle for mix of FID and OBJECTID
OIDFieldName = arcpy.Describe(inFeatureClass).OIDFieldName