1

I am trying to make a systematic cluster sampling pattern for data collection. The sampling consist of the points placed over the landscape in 6 km span (red). From this major point, I need to create 3x3 sampling spots in 200 m span (grey), in direction towards the east and south, creating L shaped cluster of points.

I was wondering, how to make this sampling scheme in ArcGIS using ArcPy?

It is pretty straightforward to generate a set of equally distributed points over the landscape using Create Fishnet tool and set Create Label Points as TRUE. Cell height and cell width will simply be 6 km.

But do you have any suggestion, how to create set of grey points located towards east and south, in 200 m distance from each other?

I honestly even don't know where to start...

enter image description here

My sample code to generate red grid points:

import arcpy, os
from arcpy import env

# Allow files to overwrite
arcpy.env.overwriteOutput = True

# Set coordinate system of the output fishnet
arcpy.env.outputCoordinateSystem = arcpy.SpatialReference(3067)

# Define working directory
inWD = "C:/Users/data/raw"

# Define variables:
inFC = os.path.join(inWD, "myFC.shp")
outFC = os.path.join(inWD, "myFC_grid.shp")

# Create fishnet
cellSizeWidth = 6000 # 6 km
cellSizeHeight = cellSizeWidth
labels = "LABELS" # Create points in the middle of squares
desc = arcpy.Describe(inFC)  # get describe object to define extent coordinates

# Process: Create fishnet
arcpy.CreateFishnet_management(out_feature_class = outFC,
                               origin_coord = str(desc.extent.lowerLeft),
                               y_axis_coord = str(desc.extent.XMin)  + " " + str(desc.extent.YMax + 100),
                               cell_width = cellSizeWidth,
                               cell_height = cellSizeHeight,
                               number_rows = "0",
                               number_columns ="0",
                               corner_coord = str(desc.extent.upperRight),
                               labels = "LABELS",
                               template = "#",
                               geometry_type = "POLYLINE")

print "basic fishnet created"

# Import newly generated point grid data ""
red_points = os.path.join(inWD, "myFC_grid_label.shp")

# Make new freature class to add new points  
grey_points = os.path.join(inWD, "Lcluster.shp")

How to add clusters points to grey dataset?

1
  • 2
    It's just a little computational geometry. You don't even need to use trig functions, just use deltas on the X and Y of the reference points. An InsertCursor based on a SearchCursor is the minimum necessary code snippet, with a description of the problem you've encountered.
    – Vince
    Oct 3, 2019 at 10:54

1 Answer 1

3

Given you already have your RED 6km span points which I am referring to red_points, you can do something like this to obtain your 3X3 200m grey_points.

(please, adjust the sign (+/-) as you wish to achieve your result. Also, here 200 is in meters as long as the units of your reference system is meter.)

import arcpy

red_points = "your_red_points_fc_here"
grey_points = "your_grey_points_fc_here"
sourceid_fld = "SourceID"

# add field "SourceID" to store the ID of the original (red) point
arcpy.AddField_management(grey_points, sourceid_fld, "LONG")

with arcpy.da.SearchCursor(red_points,["SHAPE@X", "SHAPE@Y", "OID@"]) as s_cur:
    with arcpy.da.InsertCursor(grey_points, ["SHAPE@X", "SHAPE@Y", sourceid_fld]) as i_cur:
        for row in s_cur:
            red_id = row[2]
            i_cur.insertRow((row[0] + 200, row[1], red_id))
            i_cur.insertRow((row[0] + 400, row[1], red_id))
            i_cur.insertRow((row[0] + 600, row[1], red_id))
            i_cur.insertRow((row[0], row[1] + 200, red_id))
            i_cur.insertRow((row[0], row[1] + 400, red_id))
            i_cur.insertRow((row[0], row[1] + 600, red_id))
2
  • 2
    I think this code would be improved if you copied over a red point ID to the generated grey points? So you know those grey points were generated from their respective red point.
    – Hornbydd
    Oct 3, 2019 at 16:15
  • 2
    Good point @Hornbydd. I added that in my answer.
    – umbe1987
    Oct 4, 2019 at 7:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.