randomly_selected = random.sample([str(r[0]) for r in arcpy.da.SearchCursor('Layer Name', ['SOURCE_ID_FIELD'])], 50) query = "SOURCE_ID_FIELD IN ('" + "', '".join(randomly_selected) + "')"
Cursors honor layer/table view definition queries and selections. The cursor object only contains the rows that would be used by any geoprocessing tool during an operation.
selected = [str(r[0]) for r in arcpy.da.SearchCursor('Layer Name', ['SOURCE_ID_FIELD'])] query = 'SOURCE_ID_FIELD IN (' + ', '.join(selected) + ')'
query = "SOURCE_ID_FIELD IN ('" + "', '".join(selected) + "')"
Hello, In my python script I am selecting by attribute, and after doing so I would like to make a random selection of 50 polygons from this selection. I am trying to do this in an efficient manner. I have tried a manner of different solutions, but these involve exporting files and slow for loops. Any suggestions for a fast and efficient way to perform this random selection. Thanks Fred
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.