|
POST
|
Try using the da cursor it's easier to understand. edit: For your current code on line 5 s will now hold the attribute from your "ADD_FULL" field of the first record in your feature class table. if you add the below it should print the attribute of every record in your feature class rows = arcpy.UpdateCursor(featureClass)
row = rows.next()
#AddressFieldName = "ADD_FULL"
while row:
s= row.ADD_FULL
print s
row = rows.next()
... View more
07-20-2015
07:22 AM
|
0
|
3
|
4129
|
|
POST
|
If you want a little more control you could use feature to polygon on your street center line file I'm assuming the gaps are ROWs you may have to add the lines that don't follow street features such as rivers or district boundary or other. Then you could use a spatial join and then dissolve. It sounds like a lot but goes fast and does a good job
... View more
07-20-2015
05:48 AM
|
1
|
2
|
1796
|
|
POST
|
If you have an advanced license you could use aggregate polygons
... View more
07-20-2015
05:27 AM
|
1
|
0
|
1796
|
|
POST
|
In addition to what Ian Murray said you may want to try the code as posted below. That way if the layer doesn't support label classes it will just skip it. I tested with a group layer and a raster layer neither support label classes it worked fine for the raster that supports extent and bombed on the group layer. Don't forget to change the field name
mxd = arcpy.mapping.MapDocument("CURRENT") # Using current map, can also use a path to an mxd here
df = arcpy.mapping.ListDataFrames(mxd)[0]
lyr = arcpy.mapping.ListLayers(mxd, "", df)[0]
#Check to see if layer supports label classes
#http://resources.arcgis.com/en/help/main/10.1/index.html#//00s30000002t000000
if lyr.supports("LABELCLASSES"):
for lblclass in lyr.labelClasses:
lblclass.showClassLabels = True
lblclass.expression = '"%s" & [Type] & "%s"' % ("<CLR red='255'><FNT size = '12'>", "</FNT></CLR>")
lyr.showLabels = True
#Apply extent from "Source" layer
ext = lyr.getExtent()
df.extent = ext
arcpy.RefreshActiveView()
... View more
07-19-2015
10:28 AM
|
0
|
0
|
1254
|
|
POST
|
I've commented the code to help you find out where you should place the pieces your wanting to add if you'll provide me with the requested information i will help you get it in the code.I’m on geonet to help others and to learn and in saying that I also feel compelled to try to teach. Because if you want to know something really well you should try to teach and in doing so you will greatly improve your own skill. If any one sees anything in my comments that are wrong or inconsistent with the use of the code or tool please do not be shy to comment. You will not hurt my feelings I am here to learn as much as I’m here to help. commented code ########
#information you should add these pieces of information
#Script name #the name of the script
#Author #The author of the script
#Date #date of creation it's also a good idea to add a date when you modify the
#code and list as a revision with a description of what you did and why
#Pseudo code #This would be your intial workflow thoughts to help you create the
#code below*
########
#import modules
import arcpy
#########################################
#These are the parameter settings for your tool
#tool box parameters
#point = feature set #this will allow the user to give us the xy data
#targetpoint = featurelayer #this will get the target point as a feature layer or feature layer
#parcel = featurelayer #Same as above but if we could restrict to feature layer only we
#wouldn't need to create a feature layer below
#########################################
#This website gives you a description of how to use arcpy.GetParameterAsText()
#http://resources.arcgis.com/en/help/main/10.1/index.html#//018v00000047000000
# Syntax GetParameterAsText (index)
#You always put your variables at the top I don't know why
#This is the point variable gained from the feature set the
#only thing we need from here is the xy
point = arcpy.GetParameterAsText(0)
#The target point feature class this is where we want to get data to
#you can call these variables anything you want but is always a good
#idea to call it something that makes sense for your use
targetpoint = arcpy.GetParameterAsText(1)
#The parcel file this is where we will be getting data from
parcel = arcpy.GetParameterAsText(2)
#This variable is used with make feature layer because you can't select
#by location from a feature class it needs to be a feature layer
parcel_lyr = 'parcel_lyr'
#This website gives you a description of how to use arcpy.da.SearchCursor
#http://resources.arcgis.com/en/help/main/10.2/index.html#//018w00000011000000
#There are a couple of different search cursor with different uses I won't try to
#explain them here I think it's sufficient that you are aware of them see this note
#Note:arcpy.da.SearchCursor should not to be confused with the arcpy.SearchCursor.
# Syntax SearchCursor (in_table, field_names, {where_clause}, {spatial_reference}, {explode_to_points}, {sql_clause})
for prow in arcpy.da.SearchCursor(point,'SHAPE@XY'):
#The only thing we need is the x and y
x,y = prow[0]
#You should always delete the cursor
#It often drives me crazy when I forget and can't read my data
del prow
#Not sure it's neccessary to do this part or not I probably could have created this
#in the loop above something like point1 = prow[0] would most likely would have worked
#maybe someone better than could chime in
#I'm using it here so I can get the element needed for point geometry below
point1 = arcpy.Point(x, y)
#This website gives you a description of how to use arcpy.PointGeometry
#http://resources.arcgis.com/en/help/main/10.2/index.html#//018z00000039000000
#Syntax PointGeometry (inputs, {spatial_reference}, {has_z}, {has_m})
#We'll use this in the select by location query
ptGeometry = arcpy.PointGeometry(point1)
#This website gives you a description of how to use arcpy.MakeFeatureLayer_management
#http://resources.arcgis.com/en/help/main/10.2/index.html#//00170000006p000000
# Syntax MakeFeatureLayer_management (in_features, out_layer, {where_clause}, {workspace}, {field_info})
# We need to do this in case the user selects a feature class above instead of a feature layer
arcpy.MakeFeatureLayer_management(parcel,parcel_lyr)
#This website gives you a description of how to use arcpy.SelectLayerByLocation_management
#http://resources.arcgis.com/en/help/main/10.2/index.html#//001700000072000000
# Syntax SelectLayerByLocation_management (in_layer, {overlap_type}, {select_features}, {search_distance}, {selection_type})
#Get the intesecting parcel so we can get the data
arcpy.SelectLayerByLocation_management(parcel_lyr,"INTERSECT",ptGeometry)
#We are using a field list to identify the fields we want to get from the parcel
#layer I'm also using for a few shortcuts I'll explain those when we get to them
fldList = ['TMS','OWNERNAME']
#We are creating a field dictionary here to hold the field names and the field data
#this is a shortcut so I don't have to write out every field and every row. When
#get to that part I'll give a description of how to do it the other way and with
#needing a concantination of fields in the insert cursor we may do it the other way
#so you'll be able to see it
fldDict ={}
#We are simply making sure we are only dealing with one parcel
#you could put an else statement below so if there was more or less than 1
#you could give the user a message letting them know that we got more or less
#than expected so we wont transfer any data or create a point in the targetpoint
if int(arcpy.GetCount_management(parcel_lyr).getOutput(0))==1:
#This is another searchcursor see above
for parrow in arcpy.da.SearchCursor(parcel_lyr,fldList):
#You can find explinations of for loops and python dictiionarys all over the
#web. basically we are iterating through the field list and populating
#the dictionary with the field name and the matching attribute
for x in range(len(fldList)):
fldDict[fldList ]=parrow
#again delete the cursor
del parrow
#we are creating a field attribute list to use below
fldAttList = []
#Populating the field attribute list with the attributes from the dictionary
for x in range(len(fldList)):
fldAttList.append(fldDict[fldList ])
#These are the manual fields we'll need to add them to the list of fields
manualFields = ["FacltyType", "StructType", "Verified", "Status", "StructCat"]
#We will probably change these out with a different set of fields for the target
#feature class
for fld in manualFields:
fldList.append(fld)
#These are the attributes for the manual fields
fixedAtts = ["Single Family Home","Primary, Private","Yes, GRM, TA","Active","Residential","1110"]
#Add the above attributes to the attributes list
for att in fixedAtts:
fldAttList.append(att)
#add the coordinates to the list so the point can be created
fldAttList.append(point1)
#convert field attribute list to a tuple
fldtuple = (fldAttList)
#Add the xy field so the insert cursor knows where to put the coordinates
fldList.append( 'SHAPE@XY')
#This website gives you a description of how to use arcpy.da.InsertCursor
#http://resources.arcgis.com/en/help/main/10.2/index.html#//018w0000000t000000
# Syntax InsertCursor (in_table, field_names)
#Note:arcpy.da.InsertCursor should not to be confused with arcpy.InsertCursor.
tprow = arcpy.da.InsertCursor(targetpoint,fldList)
tprow.insertRow(fldtuple)
#again delete the cursor
del tprow
... View more
07-19-2015
09:21 AM
|
2
|
4
|
1045
|
|
POST
|
Could you lay this out a little simpler for me? Would give me a list of fields from your parcels you want to transfer to the point feature class and give me the fields they go to in the point feature class and give me a list of the preset data and the fields they go to.
... View more
07-18-2015
03:47 PM
|
0
|
2
|
2526
|
|
POST
|
Brad I tested both individually and they both worked for me. See the above code for how i used them the only changes i made were labels code line 6 i changed the field name to work with the field in my data in the extent i added line 7.
... View more
07-17-2015
01:10 PM
|
0
|
3
|
1836
|
|
POST
|
Try something like below. #import modules
import arcpy
"""
tool box parameters
point param = feature set
targetpoint = featurelayer
parcel = featurelayer
"""
point = arcpy.GetParameterAsText(0)
targetpoint = arcpy.GetParameterAsText(1)
parcel = arcpy.GetParameterAsText(2)
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)
arcpy.MakeFeatureLayer_management(parcel,parcel_lyr)
arcpy.SelectLayerByLocation_management(parcel_lyr,"INTERSECT",ptGeometry)
fldList = ['TMS','OWNERNAME']
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 = ["FacltyType", "StructType", "Verified", "Status", "StructCat"]
for fld in manualFields:
fldList.append(fld)
fixedAtts = ["Single Family Home","Primary, Private","Yes, GRM, TA","Active","Residential","1110"]
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-17-2015
11:54 AM
|
2
|
9
|
2526
|
|
POST
|
Brad I tested both the labels portion and the extent portions of your script in arcmap and as a script model both worked without any issues labels mxd = arcpy.mapping.MapDocument("CURRENT") # Reference to current open map document. Could insert path.
layer = arcpy.mapping.ListLayers(mxd, "")[0] # Indexing for first layer in table of contents. "Make feature layers" functions ordered so "Source" is in 0 position.
if layer.supports("LABELCLASSES"):
for lblclass in layer.labelClasses:
lblclass.showClassLabels = True
lblclass.expression = '"%s" & [Type] & "%s"' % ("<CLR red='255'><FNT size = '12'>", "</FNT></CLR>")
layer.showLabels = True
arcpy.RefreshActiveView() Extent #Apply extent from "Source" layer
mxd = arcpy.mapping.MapDocument("CURRENT") # Using current map, can also use a path to an mxd here
df = arcpy.mapping.ListDataFrames(mxd)[0]
lyr = arcpy.mapping.ListLayers(mxd, "", df)[0]
ext = lyr.getExtent()
df.extent = ext
arcpy.RefreshActiveView()
... View more
07-17-2015
08:54 AM
|
0
|
9
|
1836
|
|
POST
|
I'm at 10.2 and sometimes have this problem. My work around is tho use the Identify tool in the map. I'll identify all the records I want using the shift key to keep adding to the identify window and then I'll go to the top of the identify window to the name of the feature class and right click and select to get the records I'm after
... View more
07-17-2015
05:08 AM
|
0
|
0
|
1420
|
|
POST
|
I set this code up to be used in a model and assumed the fields would be the same names and types it should help you get started. #import modules
import arcpy
"""
tool box parameters
point param = feature set
targetpoint = featurelayer
parcel = featurelayer
"""
point = arcpy.GetParameterAsText(0)
targetpoint = arcpy.GetParameterAsText(1)
parcel = arcpy.GetParameterAsText(2)
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)
arcpy.MakeFeatureLayer_management(parcel,parcel_lyr)
arcpy.SelectLayerByLocation_management(parcel_lyr,"INTERSECT",ptGeometry)
fldList = ['TMS','OWNERNAME']
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 ])
fldAttList.append(point1)
fldtuple = (fldAttList)
fldList.append( 'SHAPE@XY')
tprow = arcpy.da.InsertCursor(targetpoint,fldList)
tprow.insertRow(fldtuple)
del tprow
... View more
07-16-2015
07:38 PM
|
2
|
11
|
2526
|
|
POST
|
I think my workflow would be: Get XY from user (for model builder: a feature set, from an addin get the mousedown XY) Then use the XY to select by location the parcel Make feature layer from selected Use a search cursor to read the needed fields into a dictionary Then use an insertcursor on the point file to insert the row with the data from dictionary
... View more
07-16-2015
01:40 PM
|
0
|
2
|
2526
|
|
POST
|
When you your model and go to results and pick "Share as" "Geoprocessing Service" and go through the screens a dialog box comes up where you have an opportunity to publish the service but you can also analyze the service have you run the analyze portion to see if it throws any errors at you. I know if i publish a map service and i've used a layer that is not in a registered folder i'll get an error message.
... View more
07-16-2015
12:27 PM
|
0
|
1
|
2382
|
|
POST
|
You may want to move this question to an ArcGis Online groups
... View more
07-16-2015
08:45 AM
|
1
|
0
|
1737
|
| 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
|