The acquisition of the operation area of agricultural machinery is the premise for the service pricing and granting government subsidies of agricultural machinery. The objective of this paper is to develop a KNN algorithm based on amending mechanism and pruning optimization (KAP) in the case of irregular fields, which could reduce error and accelerate the process. The algorithm consists of two stages. The first stage uses KNN, generating convex or non-convex hulls that represent the area occupied by arbitrary sets of points, to detect boundary, and the second stage uses amending mechanism to correct the results obtained in the previous stage to improve the accuracy. Only the points close to the boundary could affect the detection and amending results. Based on this, the pruning optimization is used to speed up operations without sacrificing accuracy in the two stages. According to a series of accurate experiment with repeatability, compared to traditional KNN, addition of amending mechanism can reduce the error by at least 2%. The use of pruning optimization accelerates the first stage by 30% - 100% and the second stage by 2-20 times.The results illustrate that the KAP algorithm could be competent for calculation in irregular field.