|
POST
|
I need some help on my code to count the number of features inside a polygon. I have the following but after testing it, it doesn't seem to be correct. I am trying to figure out how many parcel lots are within the subdivision boundary. My test show after running the code that the "Stats" table has 9 Frequencies but in actually there is 10 parcels within the subdivision. I have tried "HAVE_THEIR_CENTER_IN" but all the results are 1. import arcpy, os
mxd = arcpy.mapping.MapDocument("current")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Taxlots")[0]
subs = arcpy.mapping.ListLayers(mxd, "SubsOutsideCities")[0]
#arcpy.MakeFeatureLayer_management(par, "parLyr")
arcpy.SpatialJoin_analysis(subs, lyr,"in_memory/points_SpatialJoin", "JOIN_ONE_TO_MANY", "KEEP_ALL", "", "CONTAINS")
arcpy.Statistics_analysis("points_SpatialJoin", "in_memory/stats", "Join_Count COUNT","OBJECTID")
... View more
03-19-2020
01:30 PM
|
0
|
12
|
4631
|
|
POST
|
Thank you for explaining "Matching characters". Thank you for the help.
... View more
03-12-2020
02:26 PM
|
0
|
0
|
1433
|
|
POST
|
Yes, this got me the closest to my goal. I was trying to understand how re.findall patterns work. The [ ] is used to match certain characters, and the reason you didn't use the [ ] was because you were trying to capture the 8 digits and the last two regardless of the alpha "B". After looking at the data i noticed that some didn't have the "B" but had 8-10 digits. I appreciate the help.
... View more
03-12-2020
02:24 PM
|
0
|
0
|
1433
|
|
POST
|
Getting closer, the other issue that i found was a lot records didn't have "B", people for got to put the "B" in front of the building permit. Some records have the following. 34567000 0
12345000 0
45125011A0
... View more
03-10-2020
11:55 AM
|
0
|
3
|
1433
|
|
POST
|
I still got the same error on the same line. I checked the field and the lowest count of words in the filed is 2 and a max of 61. I used len( !PojectIinfo! .split(" ")) to get the count of words in that field.
... View more
03-10-2020
11:51 AM
|
0
|
0
|
1433
|
|
POST
|
!PojectIinfo![ !PojectIinfo! .index("B"): !PojectIinfo! .index("B")+11]
Yes text field
... View more
03-10-2020
11:49 AM
|
0
|
0
|
1728
|
|
POST
|
sorry about that. I get the following error. IndexError: string index out of range On line if i.startswith('B') and i[1].isdigit():
... View more
03-06-2020
03:36 PM
|
0
|
2
|
1728
|
|
POST
|
After looking at the field a little closer there are Alphas characters in some records instead of a space. I need to get those as well. I would also like to add a 0 (zero) to the spaces if there is no Alph character if possible. For example: Single Family Res B34561000A0 >>> Extract B34561000A0 to BP field New SFR w/Attached Garage, covered parch and patio B24501000 0 >>>Extract B2450100000 to BP field
... View more
03-06-2020
03:35 PM
|
0
|
1
|
1433
|
|
POST
|
Yes a text field and no particular format. I get the following. if i.startswith('B') and i[1].isdigit():
... View more
03-06-2020
03:07 PM
|
0
|
4
|
1728
|
|
POST
|
I need help with extract a particulate value from the field "PojectIinfo" field. I need to only extract the value/characters of the letter B and the 10 digits after the B an place it in the field "BP". There might be a space in that value as well, for example B24501000 space 0. The total characters would be 11; B plus 10 digits. I am thinking i need to use re.compile but i am uncertain on the code. Current field looks like this. New SFR w/Attached Garage, covered parch and patio B24501000 0 >>>Extract B24501000 0 to BP field B34567000 0 30 X 48 Pole Barn >>>Extract B34567000 0 to BP field NEW 22,778 SQ FT B33561000 0 Addition to existing hop building >>>Extract B33561000 0 to BP field Residential B14356000 0 Storage>>>Extract B14356000 0 to BP field
... View more
03-06-2020
01:13 PM
|
0
|
20
|
3686
|
|
POST
|
I came up with this but your code also works but with changing the index number or in my case the layer name, thanks for the code. I do have to check "Remove duplicate labels" in the label other options. It would be nice to not have to put in the index number because I have about 30 layers on my map. def FindLabel ([OBJECTID] ):
mxd = arcpy.mapping.MapDocument("CURRENT")
lyr = arcpy.mapping.ListLayers(mxd,"1N3W")[0]
with arcpy.da.SearchCursor(lyr, ["OBJECTID"]) as cursor:
rows = {row[0] for row in cursor}
count = 0
for row in rows:
count += 1
return "%s " % count
... View more
11-25-2019
12:45 PM
|
0
|
0
|
3748
|
|
POST
|
Thanks for the replay, I should have mentioned that i am working in ArcMap.
... View more
11-25-2019
11:52 AM
|
0
|
2
|
3748
|
|
POST
|
I have a map that i need to label the total number of features(feature count) for each layer. I would like to be able to create a label expression but i can't seem to find out how to do this, the only thing that comes to mind is count[field] but that doesn't work. Similar to right clicking on a field, statistics - count but i want to able to label that layer with that count on a map on the fly. I would appreciate any help, thanks.
... View more
11-25-2019
08:23 AM
|
0
|
4
|
3891
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 10-27-2022 11:37 AM | |
| 1 | 10-31-2023 10:16 AM | |
| 1 | 02-16-2023 01:50 PM | |
| 1 | 08-11-2021 11:13 AM | |
| 1 | 01-06-2021 10:45 AM |
| Online Status |
Offline
|
| Date Last Visited |
09-10-2024
10:42 AM
|