|
POST
|
Maybe we'll see something if you post the script up to the point where it throws the error.
... View more
04-01-2016
12:04 PM
|
1
|
8
|
3642
|
|
POST
|
I am not really clear if the snaps will work with elements drawn from the Drawing toolbar like lines and rectangles, or if it just works with entities from my feature classes. I have seen posts saying it will work with both. I was more interested in seeing posts that claimed you could snap to graphics.
... View more
03-31-2016
03:11 PM
|
0
|
0
|
2012
|
|
POST
|
There's probably a fancier, more streamlined way to get to this, but here's one way to get your data ready for an insertCursor. You'll still have to create a feature class and add the appropriate fields: >>> times = set([])
... with arcpy.da.SearchCursor("Alma_Clinic_SAA_Stats$","TIME") as cursor:
... for row in cursor:
... times.add(row[0]) # get a unique list of possible times
... time_dict = {}
... for i,item in enumerate(sorted(times)):
... time_dict[item] = i + 3 # make a dictionary, with index number to fit in final table: {time1:3, time2:4, time5:5}
... dict = {}
... with arcpy.da.SearchCursor("Alma_Clinic_SAA_Stats$","*") as cursor:
... for row in cursor:
... dict.setdefault(row[0]+'-'+row[1],[row[0],row[1],row[2]] + ([0]*len(time_dict))) # make a default value: {key1:[TOWN,SETTLEMENT,NAME,0,0,0,0,0,0,0,0,0,etc.], key2...}
... dict[row[0]+'-'+row[1]][time_dict[row[3]]] = row[4] # fill in BUILDINGS at appropriate places in list
... final_rows = []
... for k,v in dict.iteritems():
... final_rows.append(v) # write out the final list, ready for insertCursor
... print final_rows
...
[[u'Mossel Bay', u'Asla Park C', u'Alma Clinic', 0, 0, 0, 0, 0, 51.0], [u'Mossel Bay', u'Asla Park B', u'Alma Clinic', 0, 0, 6.0, 148.0, 0, 0], [u'Mossel Bay', u'Asla Park A', u'Alma Clinic', 0, 0, 0, 0, 0, 411.0], [u'Mossel Bay', u'Sinethemba', u'Alma Clinic', 0, 0, 50.0, 235.0, 0, 0], [u'Mossel Bay', u'Asla Park E', u'Alma Clinic', 0, 0, 25.0, 0, 0, 0], [u'Mossel Bay', u'Asla Park D', u'Alma Clinic', 0, 0, 0, 0, 0, 133.0], [u'Mossel Bay', u'PA Camp', u'Alma Clinic', 0, 0, 0, 0, 0, 32.0], [u'Mossel Bay', u'Emfuleni', u'Alma Clinic', 0, 38.0, 102.0, 0, 0, 0], [u'Mossel Bay', u'Gentswana B', u'Alma Clinic', 0, 0, 0, 0, 32.0, 36.0], [u'Mossel Bay', u'Gentswana C', u'Alma Clinic', 0, 0, 0, 3.0, 59.0, 0], [u'Mossel Bay', u'Gentswana A', u'Alma Clinic', 0, 0, 0, 0, 15.0, 27.0], [u'Mossel Bay', u'Sewendelaan', u'Alma Clinic', 0, 0, 84.0, 17.0, 0, 0], [u'Mossel Bay', u'Transand Camp', u'Alma Clinic', 2.0, 11.0, 0, 0, 0, 0], [u'Mossel Bay', u'Thembani Street', u'Alma Clinic', 0, 0, 15.0, 101.0, 0, 0]]
... View more
03-31-2016
03:08 PM
|
0
|
6
|
5241
|
|
POST
|
As far as I know, snapping only works between geographic features, not graphic elements. Can you post links to those that suggest otherwise?
... View more
03-31-2016
02:10 PM
|
0
|
2
|
2012
|
|
POST
|
Since you're returning text, your field must be text. Remove the "Dim..." line. Dim is for VBA, not VBScript.
... View more
03-31-2016
10:40 AM
|
2
|
6
|
4212
|
|
POST
|
It seems like row and column are somewhat arbitrary (i.e. the concept of "grid" is unnecessary, as in, polygons in the same "row" don't have to be at the same approximate Y value, and "columns" don't have to be at the same X value). If that is the case, then you can think of column as a grouping variable (e.g. all the polygons in the same state would get the same value, perhaps the state FID or ANSI or any other unique attribute, via Spatial Join) and then you can increment (there are many example on GeoNet) the value for row to make a unique combination.
... View more
03-31-2016
09:17 AM
|
1
|
0
|
3860
|
|
POST
|
I'm not sure I understand what you want to happen in the case of irregular polygons (like states). Can you provide a picture? edit: based on the following comments, you may also want to provide the starting attribute table. I think most are assuming you already have the values for "Column" and "Row" populated, but I'm guessing that's your real problem.
... View more
03-30-2016
01:42 PM
|
0
|
1
|
3860
|
|
POST
|
As a lazy coder, I would only use FieldMap and FieldMappings as a last resort. They are complete outliers in the context of arcpy.
... View more
03-29-2016
01:48 PM
|
0
|
2
|
1979
|
|
POST
|
I see this post is unanswered from 4 years ago, but here goes, with Python: >>> import os # import os library
... fc = 'points' # points layer
... r_fields = arcpy.ListFields("points", "r*") # get list of fields beginning with 'r' - it will depend on your data if this is appropriate
... cell_size = 100 # cell size for IDW
... out_folder = r'C:\junk' # folder for output rasters
... for r_field in r_fields: # loop through r_fields
... outIDW = arcpy.sa.Idw(fc, r_field.name, cell_size) # run IDW considering r_field
... outIDW.save(os.path.join(out_folder,r_field.name + '.tif')) # save output
... View more
03-29-2016
01:44 PM
|
0
|
0
|
1921
|
|
POST
|
I need to hop off here for a while - just wanted you to know that yes, I completely missed the division part.
... View more
03-28-2016
10:41 AM
|
0
|
0
|
3936
|
|
POST
|
Here's what I would try. Again, untested (sorry, I'm too lazy to duplicate your raster folder setup). I'm not 100% sure that you can sum rasters using sum(), but it's worth a shot. import calendar, os # import libraries
arcpy.env.workspace = r'C:\myfolder\anotherfolder' # your workspace
for month in calendar.month_abbr: # loop through 3-letter month abbreviations
rasters = arcpy.ListRasters('*' + month.lower() + '*') # make list of matching rasters in workspace
con_rasters = [] # empty list
for raster in rasters: # loop through matching rasters
con_rasters.append(Con(IsNull(raster),0,raster)) # run Con expression and add to list
monthsum = sum(con_rasters) # add Con rasters
monthsum.save(os.path.join(r'C:\myfolder\anotherfolder',month.lower()+'sum.png' ) # save to new raster
... View more
03-28-2016
10:03 AM
|
0
|
3
|
3936
|
|
POST
|
I think you're looking for the Delete Field tool. If you need more help, please include your code within code tags so we can copy/paste/more easily read. Posting Code blocks in the new GeoNet
... View more
03-28-2016
09:42 AM
|
1
|
0
|
3248
|
|
POST
|
Untested - there may be errors: import calendar, os # import libraries
arcpy.env.workspace = r'C:\myfolder\anotherfolder' # your workspace
for month in calendar.month_abbr: # loop through 3-letter month abbreviations
rasters = arcpy.ListRasters('*' + month.lower() + '*') # make list of matching rasters in workspace
monthsum = sum(rasters) # add matching rasters together
monthsum.save(os.path.join(r'C:\myfolder\anotherfolder',month.lower()+'sum.png' ) # save to new raster
... View more
03-28-2016
09:36 AM
|
0
|
5
|
3936
|
|
POST
|
You can make a new table to hold the month names (row values = jan, feb, etc.). Then Iterate through those with Iterate Field Values. Finally, use the outputs of that simple submodel to feed into the wildcard parameter of Iterate Rasters. Unfortunately, using multiple iterators is a relatively complex way to do something very straight forward in Python. Something like: This is a list of month names.
For each month name, loop through rasters.
If the raster name contains the month name, add it and save it.
... View more
03-28-2016
09:19 AM
|
0
|
8
|
3936
|
|
POST
|
It sounds like you may be more interested in exploring ArcObjects (the real nuts and bolts of ArcGIS) than arcpy, but I could be wrong.
... View more
03-23-2016
04:25 PM
|
0
|
1
|
2972
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-25-2015 01:51 PM | |
| 1 | 08-30-2013 02:22 PM | |
| 1 | 04-12-2011 11:19 AM | |
| 1 | 09-17-2021 09:43 AM | |
| 1 | 04-04-2012 12:05 PM |
| Online Status |
Offline
|
| Date Last Visited |
07-15-2023
12:11 AM
|