POST
|
Aha. Thought I'd tried ==' ' but I guess I hadn't - that did the trick. thanks!
... View more
03-17-2017
08:45 AM
|
0
|
0
|
506
|
POST
|
I can't get this to work. I want it to return "No Data" if the field PROP_CLASS is empty (see line 32). As things stand it returns "Other." It works otherwise. Any ideas? def CATEGORY(prop_class):
if '200' <= prop_class <= '283':
return "Residential"
elif '310' <= prop_class <='312':
return "Residential"
elif prop_class == '322':
return "Residential"
elif '410' <= prop_class <= '413':
return "Residential"
elif prop_class == '416':
return "Residential"
elif prop_class == '693':
return "Residential"
elif prop_class == '300':
return "Public/Vacant"
elif '313' <= prop_class <= '321':
return "Public/Vacant"
elif '323' <= prop_class <= '380':
return "Public/Vacant"
elif prop_class == '531':
return "Public/Vacant"
elif prop_class == '552':
return "Public/Vacant"
elif prop_class == '560':
return "Public/Vacant"
elif '590' <= prop_class <= '593':
return "Public/Vacant"
elif prop_class == '695':
return "Public/Vacant"
elif '900' <= prop_class <= '994':
return "Public/Vacant"
elif prop_class is None:
return "No Data"
else:
return "Other"
... View more
03-17-2017
08:35 AM
|
0
|
4
|
1134
|
POST
|
Amazing! It worked perfectly and saved tons of time. I ran it for one county's worth of block groups and got the same results as my model. So fast. Perfect. Thanks!
... View more
03-10-2017
12:29 PM
|
1
|
0
|
1060
|
POST
|
Ah, I see. Unfortunately I have to clip the tax parcels with the block groups, in order to avoid capturing area that's not in the block group.
... View more
03-08-2017
01:06 PM
|
0
|
2
|
1060
|
POST
|
I don't have any reason to do them one by one! I don't quite get your drift re: "identity operation" but would welcome suggestions to get this result.
... View more
03-08-2017
11:51 AM
|
0
|
5
|
1060
|
POST
|
I have a model that iterates through feature classes, does a calculation, and puts out feature classes. I now need to run it on a GDB containing over 15000 fcs, which is time-consuming and cumbersome. I wonder if anyone can help me alter the model so that, instead of iterating through a GDB, it will iterate through the rows in a single shapefile, do the same calculation, and put out a single shapefile with a new field containing the calculation result (or fill in an existing blank field). I have attached the toolbox here. The inputs will be changed: they will be a shapefile containing all New York State block groups, and a shapefile containing all New York State tax parcels. The model calculates the percentage of each block group that is residential, based on a field in the tax parcel shapefile called "GOSR_CAT". I suspect I need to use a different iterator (row selection?) but have no experience doing that. I don't know how to select a row, run the calculation, and fill in a field, all in the same shapefile.
... View more
03-08-2017
10:27 AM
|
0
|
7
|
1861
|
POST
|
Is there a way to get the script to skip blank FCs? There shouldn't be any but I can't be sure.
... View more
03-08-2017
08:20 AM
|
0
|
3
|
367
|
POST
|
Oh, I see, sorry. Sure enough, there's no data in that FC. I guess that's why it stopped?
... View more
03-08-2017
08:03 AM
|
0
|
5
|
746
|
POST
|
Stopped at 1783. I'm not sure what you mean about data - there is data for all of the feature classes in the source geodatabase, and there is also data in the generated csv, which is correct, as noted above. The csv has a line for each of the 1783 fcs and nothing more.
... View more
03-08-2017
07:56 AM
|
0
|
7
|
746
|
POST
|
OK, I ran this again, as follows: import arcpy
output_file = r'C:\Users\mlenore\Desktop\GIS_Working_Folder\Residential_model\bgs.csv'
arcpy.env.workspace = r'C:\Users\mlenore\Desktop\GIS_Working_Folder\Residential_model\bgs_finished_2.gdb'
print("Listing feature classes...")
feature_classes = arcpy.ListFeatureClasses()
print("Found {0} feature classes".format(len(feature_classes)))
first_fc = feature_classes[0]
fieldnames = [f.name for f in arcpy.ListFields(first_fc) if f.type.lower() != 'geometry']
delimiter = ','
print(fieldnames) #line 10
with open(output_file, 'w') as fl:
print('Writing to {0}'.format(output_file))
# write header
fl.write(delimiter.join(fieldnames) + "\n")
# append attributes from each feature class
for fc in feature_classes:
print(fc)
with arcpy.da.SearchCursor(fc, field_names=fieldnames) as sc:
for row in sc:
fl.write(delimiter.join(map(str, row)) + '\n')
del row
del sc but it stopped before finishing all the feature classes and I got the following: Runtime error Traceback (most recent call last): File "<string>", line 23, in <module> NameError: name 'row' is not defined FYI it processed 1700 or so out of the approximately 15,000 FCs before stopping. The csv file has those correctly. Please let me know if you have any ideas. Thanks for this excellent script.
... View more
03-08-2017
07:09 AM
|
0
|
9
|
746
|
POST
|
It was indented properly, and I ran it all at once - just copied and pasted above and lost formatting.
... View more
03-07-2017
11:41 AM
|
0
|
0
|
746
|
POST
|
I let this script run overnight, and this morning, here's what I found: >>> import arcpy ... output_file = r'C:\Users\mlenore\Desktop\GIS_Working_Folder\Residential_model\bgs.csv' ... arcpy.env.workspace = r'C:\Users\mlenore\Desktop\GIS_Working_Folder\Residential_model\BGs_finished.gdb' ... print("Listing feature classes...") ... feature_classes = arcpy.ListFeatureClasses() ... print("Found {0} feature classes".format(len(feature_classes))) ... first_fc = feature_classes[0] ... fieldnames = [f.name for f in arcpy.ListFields(first_fc) if f.type.lower() != 'geometry'] ... delimiter = ',' ... ... print(field_names) ... with open(output_file, 'w') as fl: ... print('Writing to {0}'.format(output_file)) ... # write header ... fl.write(delimiter.join(fieldnames) + "\n") ... ... # append attributes from each feature class ... for fc in feature_classes: ... print(fc) ... with arcpy.da.SearchCursor(fc, fieldnames) as sc: ... for row in sc: ... fl.write(delimiter.join(map(str, row)) + '\n') ... del row ... del sc ... Listing feature classes... Found 15727 feature classes Runtime error Traceback (most recent call last): File "<string>", line 11, in <module> NameError: name 'field_names' is not defined
... View more
03-07-2017
06:21 AM
|
0
|
6
|
1171
|
POST
|
This seems like exactly what I need. Please forgive the novice question, but with what, if anything, am I to replace 'geometry' and "\n"? I have tried running this, but ArcMap just hangs.
... View more
03-06-2017
06:55 AM
|
0
|
19
|
1171
|
POST
|
Thanks for replying - but I don't need that table. I need a new table based on my model's results, which are in a geodatabase. The geodatabase contains one shapefile per BG with new data appended to each.
... View more
03-02-2017
09:11 AM
|
0
|
0
|
1171
|
Title | Kudos | Posted |
---|---|---|
1 | 03-10-2017 12:29 PM | |
1 | 03-02-2017 08:40 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|