Select to view content in your preferred language

How to use the NEAR Class: the basics ?

652
1
03-30-2013 01:36 PM
EricPlante
New Contributor
(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
0 Kudos
1 Reply
MarkBaird
Esri Regular Contributor
Hi

Your question looks like it relates to ArcObjects (ArcGIS Engine?) and not the Runtime SDK for Java SE which is a new product from ESRI which has been written from the ground up and contains no ArcObjects...

Sprry your post keeps on needing to be moved, but I'll forward it to the ArcObjects forum and you will get a better answer.

Good luck

Mark
0 Kudos