I have a very basic knowledge in Python and arcpy. I want to create a stratified random sampling point on a continuous polygon. So far, I have dissolved the polygon (according to categories) and calculated their percent area; multiplied the extracted area by total number of points, eg 3000. This gives me number of points in each polygon, according to the proportion of area of each polygon. So far I have [FID, categories, PolygonArea, PercentArea, NumberPoints]. Secondly, I want to use "Create random points" tool on each row (categories) to create points (NumberPoints) shapefiles for each row (to be stored in a scratch workspace). And thirdly, I want to merge all the point shapefiles to one point shapefile.
To accomplish this, I am currently at my second step- trying to extract the parameters (such as constraining feature class, constraining extent etc.) of "Create random points too" by using
arcpy.da.SearchCursor on list of fields ["FID", "Categories", "PolygonArea", "PercentArea", "NumberPoints"]. But I am failing to extract.
I was wondering, could I even do so? The error I am getting is-
RuntimeError: Too few parameters Expected 1.
Here is loop of the code:
with arcpy.da.SearchCursor(fc, ["FID", "Categories" "Polygon_Area", "Percent_Area", "Number_point"]) as cursor: for row in cursor: constrinaing_extent = row number_points = row arcpy.CreateRandomPoints_management("C:/Users/dguru/Desktop/Project/scratch","samplepoints.shp", constraining_extent, number_points) del row del cursor
I followed the answer syntax. But my problem and the error remains the same. To check where it is creating problem, I inserted print statement and changed the number of field to just one; it works fine and prints the polygon area for each row. But gives the same error if I want to extract multiple parameters(Polygon_Area= Fcextent; and number_points). So, the error under message section is displayed for the line where loop starts-"for row in cursor" (displaying the same error I mentioned), when I put more fields. Therefore, I am not able to extract the multiple parameters for tool.
Here is the code that worked extracting just one parameter by putting just one field); The #ed lines in the code are inactive, as I was checking where the code went wrong.
with arcpy.da.SearchCursor(fc, ["Polygon_Area"]) as cursor: for row in cursor: fc_extent = row #number_points = row print fc_extent #arcpy.CreateRandomPoints_management("C:/Users/nim/Downloads/pr.mdb", "randompoint", "", fc_extent, number_points) del row del cursor