POST
|
Awesome thank you!! I made both those changes and it runs error free!! One more quick question though, is there a way to bypass the interface that pops up when running a script where you would typically have user inputs? I click on the script in the toolbox then the interface pops up and says there are no input parameters and I have to hit ok on it also then it will run. Its not a big deal but it would be nice if it just runs when you click on the script.
... View more
01-17-2013
03:51 AM
|
0
|
0
|
1062
|
POST
|
Hello I am getting an error 000464: Cannot get exclusive schema lock. Either being edited or in use by another application. Failed to execute deletefield import arcpy
arcpy.env.workspace = "W:\ENG\Geomatics\GIS\Eastern Region Geodatabase.gdb"
arcpy.geoprocessing.env.overwriteOutput = True
arcpy.Buffer_analysis("ER_5_Year_Program", "W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities\Program_Buff", "350 METERS", "FULL", "FLAT", "NONE")
targetFeatures = "W:\ENG\Geomatics\GIS\Eastern Region Geodatabase.gdb\ER_Culverts"
joinFeatures = "W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities\Program_Buff"
outfc = "W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities\Culvert_5YCP.shp"
fieldmappings = arcpy.FieldMappings()
fieldmappings.addTable("ER_Culverts")
fieldmappings.addTable("W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities\Program_Buff.shp")
GWPFieldIndex = fieldmappings.findFieldMapIndex("GWP")
fieldmap = fieldmappings.getFieldMap(GWPFieldIndex)
field = fieldmap.outputField
field.name = "WP"
field.length = "100"
fieldmap.outputField = field
fieldmap.mergeRule = "Join"
fieldmap.joinDelimiter = ","
fieldmappings.replaceFieldMap(GWPFieldIndex, fieldmap)
arcpy.SpatialJoin_analysis("ER_Culverts", "W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities\Program_Buff.shp", outfc,"JOIN_ONE_TO_ONE","KEEP_COMMON", fieldmappings)
arcpy.ResetEnvironments()
arcpy.env.workspace = "W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities"
arcpy.Select_analysis("Culvert_5YCP.shp", "Culverts_to_Review", '''"STD_CND" in ('Poor', 'Very Poor', 'Unknown', '')''')
arcpy.DeleteField_management("Culverts_to_Review", "COMMENT;YEAR;Join_Count;TARGET_FID;Shape_Le_1;BUFF_DIST")
arcpy.Delete_management("Culvert_5YCP.shp")
arcpy.Delete_management("Program_Buff.shp") The culverts to review.shp is in a file on our network drive and not in a gdb, no one else is accessing it but me. Any ideas as to why I would be getting this error? Thanks
... View more
01-16-2013
09:37 AM
|
0
|
3
|
5418
|
POST
|
I am not sure what I am doing wrong here. Any suggestions?? import arcpy
targetFeatures = "W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities\Culvert_subset.shp"
joinFeatures = "W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities\5yrContract_subset.shp"
outfc = "W:\ENG\Geomatics\GIS\Map & Data Requests\Contracts\Maintenance\Culverts\Data\Culvert Utilities\Culvert_5YCP.shp"
fms = arcpy.FieldMappings()
fieldmappings.addTable(targetFeatures)
fieldmappings.addTable(joinFeatures)
... View more
01-14-2013
04:30 AM
|
0
|
1
|
1384
|
POST
|
I am trying to move through my contractBuffer layer record by record. For each record I want to select the culverts from the culvert_subset that fall within that record. Then take the value from the GWP field from my contractBuffer layer and populate the GWP field in the culvert subset for all those that fall within that first record. Then move to the second record in the contract buffer layer select all the culverts that fall within and so on. I know that I need to be using searchcursor and updatecursor. I think this is close to what I need to be doing however I am not sure and know that I am missing pieces. If anybody could help or make suggestions that would be great!! Thank you! import arcpy
Srlist = []
rows = arcpy.SearchCursor("Contract_Buff")
row = rows.next()
while row:
Srlist.append(row.getValue("GWP"))
row = rows.next()
Cul_rows = arcpy.UpdateCursor("Culvert_subset",GWP)
while Cul_row:
for Cul_row in Cul_rows:
(i think this is where my query needs to go to select only those culverts that fall within the boundary of the first record in the contract buff...not sure how)
row.updateRow(row)
Cul_row = Cul_rows.next()
... View more
01-10-2013
10:52 AM
|
0
|
1
|
697
|
POST
|
I am just trying it in the python window right now, but it will be a piece to a tool that I am working on.
import arcpy
arcpy.env.workspace = "W:\ENG\Geomatics\PROJECT\Python Script"
arcpy.Buffer_analysis("5yrContract_subset", "Cont_Buff", "50 METERS", "FULL", "FLAT", "NONE")
arcpy.SelectLayerByLocation_management("Culvert_subset", "INTERSECT", "Cont_Buff")
arcpy.SelectLayerByAttribute_management("Culvert_subset","SUBSET_SELECTION", '''"STD_CND" in ('poor', 'Very Poor' '')'''
Parsing error <type 'exceptions.SyntaxError'>: invalid syntax (line 8)
... View more
01-09-2013
10:08 AM
|
0
|
0
|
312
|
POST
|
I am trying to run an array where it loops through my "Cont_Buff" layer selects the first record, then selects all the culverts from the "Culvert_subset" layer that fall within that first record. Then takes the GWP value from the "Cont_Buff" layer and applies it to the WP field for all the selected culverts in the "Culvert_subset" layer. Once it has done this for the first record loop back and do the same for the second record in the "Cont_Buff" layer and so on. However I have not been able to make it run past the loop because I am getting an 'str object has no attibute error'. My OBJECTID type is not string it is Long. I've included the entire code block. rows = arcpy.SearchCursor("Cont_Buff")
row = rows.next()
CUL_rows = arcpy.UpdateCursor("Culvert_subset")
CUL_row = rows.next()
while row:
a = row.OBJECTID
"OBJECTIDS".append(a)
row = rows.next()
#Set Count equal to the length of the array created in the while loop
Count = len("OBJECTID")
#iterate through each individual feature by using a definition query
while Position < Count:
query = "[OBJECTID] = " + "'" + OBJECTIDs[Position] + "'"
"Cont_BUff".definitionQuery = query
#center on feature
df.panToExtent("Cont_Buff".getSelectedExtent())
#Select all of the Culverts Cells within the active Site Boundary
arcpy.SelectLayerByLocation_management("Culvert_subset","COMPLETELY_WITHIN","Cont_Buff",0,"NEW_SELECTION")
#Set [WP] equal to Cont_Buff[GWP]
hopper = '"' + str(OBJECTIDs[Position]) + '"'
arcpy.CalculateField_management("Culvert_subset","WP",hopper,"VB","#") I am not sure if this is even the correct way to do this seeing as how I cant get past the loop. Any suggestions?
... View more
01-09-2013
09:31 AM
|
0
|
1
|
1483
|
POST
|
I tried those changes and got an invalid syntax error. STD_CND is a field within the Culvert_subset layer in which I am wanting to select all the culverts with a rating of poor, very poor or no rating
... View more
01-09-2013
09:01 AM
|
0
|
0
|
312
|
POST
|
I am trying to write a script that runs a select by location then a subset selection of select by attribute but I keep getting an invalid expression error. The last where clause is to selected any blank fields in the STD_CND field. arcpy.SelectLayerByLocation_management("Culvert_subset", "INTERSECT", "Cont_Buff") arcpy.SelectLayerByAttribute_management("Culvert_subset","SUBSET_SELECTION",'"STD_CND" = poor' or '"STD_CND = Very Poor' or '"STD_CND" = ""') Additionally once this selection is made will it continue (or be saved) through the rest of the script or should I create a new shapefile from it? Any thoughts? Thanks!
... View more
01-09-2013
08:46 AM
|
0
|
5
|
854
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|