|
POST
|
I tweaked the code a little to make it easier to read and tested and everything appears to be working. #import modules
import arcpy
"""
tool box parameters
point param = feature set
targetpoint = featurelayer
parcel = featurelayer
"""
arcpy.env.qualifiedFieldNames = False
point = arcpy.GetParameterAsText(0) #point feature set
targetpoint = "PointsTest" #target point feature class
parcel = "ParcelsTest" #parcel feature class
parcel_lyr = 'parcel_lyr'
for prow in arcpy.da.SearchCursor(point,'SHAPE@XY'):
x,y = prow[0]
del prow
point1 = arcpy.Point(x, y)
ptGeometry = arcpy.PointGeometry(point1)
CC_list = []
with arcpy.da.SearchCursor(targetpoint, ["AddressID"]) as cursor:
for row in cursor:
try:
if "CC" in row[0]:
CC_list.append(int(row[0].strip("CC")))
except TypeError:
pass
del cursor
CC_list.sort()
AddressID = CC_list[-1] + 1
AddressID = 'CC' + str(AddressID)
arcpy.MakeFeatureLayer_management(parcel,parcel_lyr)
arcpy.SelectLayerByLocation_management(parcel_lyr,"INTERSECT",ptGeometry)
fldList = ['ACCOUNT','OwnerName','SiteAddres','SiteNum','siteNumSfx','Predir','SiteStreet', 'StreetType', 'Postdir', 'SiteCity', 'SiteZip']
fldDict ={}
#Check that we only have one parcel and get the attributes from it
if int(arcpy.GetCount_management(parcel_lyr).getOutput(0))==1:
for parrow in arcpy.da.SearchCursor(parcel_lyr,fldList):
for w in range(len(fldList)):
fldDict[fldList ]=parrow
del parrow
targetFields = ['ACCOUNT', 'OwnerName', 'SiteAddres', 'SiteNum', 'siteNumSfx', 'Predir', 'Postdir', 'SiteCity', 'SiteZip',
'SiteState', 'FacltyType', 'StructType', 'GIS_STEW', 'UpdateBy', 'Verified', 'Status', 'StructCat', 'APA_CODE',
'AddressID', 'POINT_X', 'POINT_Y', 'StreetName']
tprows = arcpy.da.InsertCursor(targetpoint, targetFields)
row = []
#Attributes from parcels
row.append(fldDict['ACCOUNT'])
row.append(fldDict['OwnerName'])
row.append(fldDict['SiteAddres'])
row.append(fldDict['SiteNum'])
row.append(fldDict['siteNumSfx'])
row.append(fldDict['Predir'])
row.append(fldDict['Postdir'])
row.append(fldDict['SiteCity'])
row.append(fldDict['SiteZip'])
#Preset attributes
row.append('ID')
row.append('Single Family Home')
row.append('Primary, Private')
row.append('CanyonCo')
row.append('TA')
row.append("Yes, GRM, TA")
row.append('Active')
row.append('Residential')
row.append('1110')
row.append(AddressID)
row.append(x)
row.append(y)
row.append(fldDict['SiteStreet'] + " " + fldDict['StreetType'])
tupleRow = (row)
tprows.insertRow(tupleRow)
del tprows
... View more
07-22-2015
07:05 AM
|
2
|
5
|
2205
|
|
POST
|
Would be willing to upload a sample of the parcel file(4 or 5 parcels) and a sample of the target point file?
... View more
07-21-2015
07:46 AM
|
0
|
8
|
2205
|
|
POST
|
I forgot to remove them from the fldList try this #import modules
import arcpy
"""
tool box parameters
point param = feature set
targetpoint = featurelayer
parcel = featurelayer
"""
arcpy.env.qualifiedFieldNames = False
point = arcpy.GetParameterAsText(0) #point boolen
targetpoint = "CCAP1" #target point feature class
parcel = "parcels" #target feature class
parcel_lyr = 'parcel_lyr'
for prow in arcpy.da.SearchCursor(point,'SHAPE@XY'):
x,y = prow[0]
del prow
point1 = arcpy.Point(x, y)
ptGeometry = arcpy.PointGeometry(point1)
CC_list = []
with arcpy.da.SearchCursor(targetpoint, ["AddressID"]) as cursor:
for row in cursor:
try:
if "CC" in row[0]:
CC_list.append(int(row[0].strip("CC")))
except TypeError:
pass
del cursor
CC_list.sort()
AddressID = CC_list[-1] + 1
AddressID = 'CC' + str(AddressID)
arcpy.MakeFeatureLayer_management(parcel,parcel_lyr)
arcpy.SelectLayerByLocation_management(parcel_lyr,"INTERSECT",ptGeometry)
fldList = ['ACCOUNT','OwnerName','SiteAddres','SiteNum','siteNumSfx','Predir','SiteStreet', 'StreetType', 'Postdir', 'SiteCity', 'SiteZip']
fldDict ={}
#setvalue = ('SiteStreet'+ 'StreetType')
if int(arcpy.GetCount_management(parcel_lyr).getOutput(0))==1:
for parrow in arcpy.da.SearchCursor(parcel_lyr,fldList):
for w in range(len(fldList)):
fldDict[fldList ]=parrow
del parrow
fldAttList = []
#You Can Change this to a name better suited for your concatenated field
newfld = str(fldDict["SiteStreet"]) +" "+str(fldDict["StreetType"])
#This Takes them out of the loop
del fldDict["SiteStreet"]
del (fldDict["StreetType"])
fldList.remove("SiteStreet")
fldList.remove("StreetType")
for w in range(len(fldList)):
fldAttList.append(fldDict[fldList ])
manualFields = ["SiteState","FacltyType", "StructType","GIS_STEW", "UpdateBy","Verified", "Status", "StructCat", "APA_CODE","AddressID", "POINT_X", "POINT_Y","StreetName"]
for fld in manualFields:
fldList.append(fld)
fixedAtts = ["ID","Single Family Home","Primary, Private","CanyonCo", "TA", "Yes, GRM, TA","Active","Residential","1110", AddressID, x, y,newfld]
for att in fixedAtts:
fldAttList.append(att)
fldAttList.append(point1)
fldtuple = (fldAttList)
fldList.append( 'SHAPE@XY')
tprow = arcpy.da.InsertCursor(targetpoint, fldList)
tprow.insertRow(fldtuple)
del tprow
... View more
07-21-2015
07:11 AM
|
2
|
1
|
2343
|
|
POST
|
Try this http://blogs.esri.com/esri/arcgis/2011/08/25/generating-a-choice-list-from-a-field/
... View more
07-21-2015
06:13 AM
|
0
|
2
|
1711
|
|
POST
|
See the notes in the code below #import modules
import arcpy
"""
tool box parameters
point param = feature set
targetpoint = featurelayer
parcel = featurelayer
"""
arcpy.env.qualifiedFieldNames = False
point = arcpy.GetParameterAsText(0) #point boolen
targetpoint = "CCAP1" #target point feature class
parcel = "parcels" #target feature class
parcel_lyr = 'parcel_lyr'
for prow in arcpy.da.SearchCursor(point,'SHAPE@XY'):
x,y = prow[0]
del prow
point1 = arcpy.Point(x, y)
ptGeometry = arcpy.PointGeometry(point1)
CC_list = []
with arcpy.da.SearchCursor(targetpoint, ["AddressID"]) as cursor:
for row in cursor:
try:
if "CC" in row[0]:
CC_list.append(int(row[0].strip("CC")))
except TypeError:
pass
del cursor
CC_list.sort()
AddressID = CC_list[-1] + 1
AddressID = 'CC' + str(AddressID)
arcpy.MakeFeatureLayer_management(parcel,parcel_lyr)
arcpy.SelectLayerByLocation_management(parcel_lyr,"INTERSECT",ptGeometry)
fldList = ['ACCOUNT','OwnerName','SiteAddres','SiteNum','siteNumSfx','Predir','SiteStreet', 'StreetType', 'Postdir', 'SiteCity', 'SiteZip']
fldDict ={}
if int(arcpy.GetCount_management(parcel_lyr).getOutput(0))==1:
for parrow in arcpy.da.SearchCursor(parcel_lyr,fldList):
for w in range(len(fldList)):
fldDict[fldList ]=parrow
del parrow
fldAttList = []
#You Can Change this to a name better suited for your concatenated field
newfld = str(fldDict["SiteStreet"]) +" "+str(fldDict["StreetType"])
#This Takes them out of the loop
del fldDict["SiteStreet"]
del (fldDict["StreetType"]
for w in range(len(fldList)):
fldAttList.append(fldDict[fldList ])
manualFields = ["SiteState","FacltyType", "StructType","GIS_STEW", "UpdateBy","Verified", "Status", "StructCat", "APA_CODE","AddressID", "POINT_X", "POINT_Y",PutYourConcatenatedFieldHere]
for fld in manualFields:
fldList.append(fld)
#if you change newfld change it here too
fixedAtts = ["ID","Single Family Home","Primary, Private","CanyonCo", "TA", "Yes, GRM, TA","Active","Residential","1110",AddressID,x,y,newfld ]
for att in fixedAtts:
fldAttList.append(att)
fldAttList.append(point1)
fldtuple = (fldAttList)
fldList.append( 'SHAPE@XY')
tprow = arcpy.da.InsertCursor(targetpoint,fldList)
tprow.insertRow(fldtuple)
del tprow
else:
arcpy.AddMessage("Number of parcels selected incorrect for this process")
... View more
07-21-2015
05:31 AM
|
0
|
3
|
2343
|
|
POST
|
Because you also have to change it in the for loops. So it's lines 45,46 and 49,50. You should also be getting the coordinated of the data frame even though it's not set explicitly
... View more
07-20-2015
06:01 PM
|
0
|
10
|
2343
|
|
POST
|
The x isn't populating correctly because it was reused in line 45 and 49 change those to different letters and that should fix that part edit are the "SiteStreet" & StreetType" fields both being used in the target point feature class or are they going to another field?
... View more
07-20-2015
01:31 PM
|
2
|
17
|
2343
|
|
POST
|
Try selecting some points lines or polygons in the CAD tables and then zoom to selected that should get where you can see it.
... View more
07-20-2015
12:37 PM
|
0
|
0
|
5306
|
|
POST
|
There is a feature to polygon tool the lines must intersect to create polygons
... View more
07-20-2015
12:21 PM
|
0
|
0
|
1873
|
|
POST
|
I've attached the code with the else statement in it with a simple message returned to the user, I also included the tool used. As far as creating multiple points for doing a subdivision i think i would start a new script and get it to work and either use as stand alone tool or incorporate into this tool. I think i would more lean towards using it as a stand alone, but that's just my opinion. You may also want to look into LGIM sounds like your doing address points and there some tools that work with the LGIM that will help with creating address points, not to mention a good format for storing your data.
... View more
07-20-2015
11:10 AM
|
0
|
2
|
1047
|
|
POST
|
Man that's great you were able to get all that in If i read correctly the only thing you needed were the Point_X and Point_Y fields I added them to code below. #import modules
import arcpy
"""
tool box parameters
point param = feature set
targetpoint = featurelayer
parcel = featurelayer
"""
arcpy.env.qualifiedFieldNames = False
point = arcpy.GetParameterAsText(0) #point boolen
targetpoint = "CCAP1" #target point feature class
parcel = "parcels" #target feature class
parcel_lyr = 'parcel_lyr'
for prow in arcpy.da.SearchCursor(point,'SHAPE@XY'):
x,y = prow[0]
del prow
point1 = arcpy.Point(x, y)
ptGeometry = arcpy.PointGeometry(point1)
CC_list = []
with arcpy.da.SearchCursor(targetpoint, ["AddressID"]) as cursor:
for row in cursor:
try:
if "CC" in row[0]:
CC_list.append(int(row[0].strip("CC")))
except TypeError:
pass
del cursor
CC_list.sort()
AddressID = CC_list[-1] + 1
AddressID = 'CC' + str(AddressID)
arcpy.MakeFeatureLayer_management(parcel,parcel_lyr)
arcpy.SelectLayerByLocation_management(parcel_lyr,"INTERSECT",ptGeometry)
fldList = ['ACCOUNT','OwnerName','SiteAddres','SiteNum','siteNumSfx','Predir','SiteStreet', 'StreetType', 'Postdir', 'SiteCity', 'SiteZip']
fldDict ={}
if int(arcpy.GetCount_management(parcel_lyr).getOutput(0))==1:
for parrow in arcpy.da.SearchCursor(parcel_lyr,fldList):
for x in range(len(fldList)):
fldDict[fldList ]=parrow
del parrow
fldAttList = []
for x in range(len(fldList)):
fldAttList.append(fldDict[fldList ])
manualFields = ["SiteState","FacltyType", "StructType","GIS_STEW", "UpdateBy","Verified", "Status", "StructCat", "APA_CODE","AddressID", "POINT_X", "POINT_Y" ]
for fld in manualFields:
fldList.append(fld)
fixedAtts = ["ID","Single Family Home","Primary, Private","CanyonCo", "TA", "Yes, GRM, TA","Active","Residential","1110",AddressID,x,y ]
for att in fixedAtts:
fldAttList.append(att)
fldAttList.append(point1)
fldtuple = (fldAttList)
fldList.append( 'SHAPE@XY')
tprow = arcpy.da.InsertCursor(targetpoint,fldList)
tprow.insertRow(fldtuple)
del tprow
... View more
07-20-2015
08:49 AM
|
0
|
0
|
1047
|
|
POST
|
I don't understand what your after did you want to move the data to another field or maybe use another field to manipulate the data? To get another field in the method your using you would just do x = row.someotherfield then s+x would equal the values of s and x. If you give me more details or an example I could help you better.
... View more
07-20-2015
08:35 AM
|
0
|
1
|
4138
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | 09-14-2015 01:29 PM | |
| 1 | 01-26-2016 10:18 AM | |
| 1 | 08-18-2015 06:01 AM | |
| 1 | 06-20-2016 12:34 PM | |
| 1 | 01-19-2016 06:13 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|