2

My situation

Input: point data from planting file

Feature Attribute:
    [('DeletionFlag', 'C', 1, 0), ['Field', 'C', 254, 0], ['Dataset', 'C', 254, 0], ['Product', 'C', 254, 0], ['Obj__Id', 'N', 15, 4], ['Time', 'D', 8, 0], ['Duration_s', 'N', 15, 4], ['Area_Count', 'C', 254, 0], ['Elevation_', 'N', 15, 4], ['Swth_Wdth_', 'N', 15, 4], ['Y_Offset_f', 'N', 15, 4], ['Distance_f', 'N', 15, 4], ['Track_deg_', 'N', 15, 4], ['Rt_Apd_Ct_', 'N', 15, 4], ['Tgt_Rate_k', 'N', 15, 4], ['Pass_Num', 'N', 15, 4], ['Seed_Cnt__', 'N', 15, 4], ['Plant_Pop_', 'N', 15, 4], ['Speed_mph_', 'N', 15, 4], ['Prod_ac_h_', 'N', 15, 4], ['Prdt_Amt', 'N', 15, 4], ['Date', 'D', 8, 0], ['Population', 'N', 15, 4], ['Product___', 'C', 254, 0]]

Sample data

https://drive.google.com/drive/folders/1RLflZNFrN0n0Ew35hTTyorecvo-l_ISq?usp=sharing

I have successfully created polygon from point data using below link Code: Creating Polygon Shapefile from Point data using QGIS?

import shapefile
import math
fileName='planting';
sf = shapefile.Reader("planting/" + fileName )
print(sf.fields)
w = shapefile.Writer('swath/' + fileName)
w.field('Product', 'C')
def rotate(point, angle):
    angle *= math.pi / 180.
    px, py = point
    qx = math.cos(angle) * px - math.sin(angle) * py
    qy = math.sin(angle) * px + math.cos(angle) * py
    return qx, qy

def translate(point, translation):
    return [point[0] + translation[0], point[1] + translation[1]]

def rectangle(width, height, angle, center):
    p1 = (-width/2, -height/2)
    p2 = (-width/2, +height/2)
    p3 = (+width/2, +height/2)
    p4 = (+width/2, -height/2)
    rotated = [rotate(p, angle) for p in [p1, p2, p3, p4]]
    translated = [translate(p, center) for p in rotated]
    return translated

for feature in  sf.shapeRecords():
    width = 0.8 * 0.3048 * feature.record['Swth_Wdth_'] / 100000  # MAGIC
    length = 1.2 * 0.3048 * feature.record['Distance_f'] / 100000  # MAGIC
    direction = feature.record['Track_deg_']
    rate = feature.record['Rt_Apd_Ct_']
    product= feature.record['Product']
    center = feature.shape.points[0];
    points = rectangle(width, length, -direction, center)
    w.poly([points])
    w.record(product)

Point data enter image description here

Swath view enter image description here this is implemented in python

I need to find

The swath view we have achieved from the point data in the planting file is not as desired. On certain areas in the field, some sensors in the swath are turned off, hence the effective swath width decreases. In our case, this is being plotted on top of the existing swath row.

How can we handle the varying swath widths when sensors are turned off?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.