frmap1

How to use the NEAR Class: the basics ?

Discussion created by frmap1 on Mar 30, 2013
Latest reply on Mar 31, 2013 by MBaird-esristaff
(This post was sent in the geoprocessing forum, but I moved it here)

I'm using the Java SDK in Eclipse.

I want to determine the distance between a point (in a first shapefile) and the nearest point amongs a set of many points (in a second shapefile).

For this purpose, I use the Near Class, but my simple code contain an error (see below). The shapefiles that I use have successfully been used in the Buffer Class in another code, so it seems that I dont use the NEAR class correctly.

I would appreciate if you could explain how the NEAR class should be used.

I'm using these lines of code:

//// Java code begins here

// Create a Near object, with both input shapefiles in the constructor
Near near = new Near("D:\\myPosition.shp","D:\\myManyPositions.shp");

// Create a geoprocessor and execute the Near object
GeoProcessor gp = new GeoProcessor();
IGeoProcessorResult result1 = gp.execute(near, null);

//// Java code ends here

Outcomes