Just Launched: You can now import projects and releases from Google Code onto SourceForge
We are excited to release new functionality to enable a 1-click import from Google Code onto the Allura platform on SourceForge. You can import tickets, wikis, source, releases, and more with a few simple steps. Read More
As far as I know the Geotools2 API does not directly provide this
functionality. However, geotools2 can be used to access your data and
get a reference to the geometry as a JTS geometry object (from a
Looking at the JTS 1.3 api (I do not have 1.4 javadocs here on disk),
there is a DistanceOp class in the
com.vividsolutions.jts.operation.distance package. Of course,
calculating the distance between all the features in your dataset and
feature x is slow for a large dataset. So, you will probably want to use
one of the indexes in com.vividsolutions.jts.index to quickly find all
the features within a bounding box / search distance first.
I am not sure if this functionality is in any other libraries, but being
a common operation, it probably is.
Hope that helps,
P.S. I have cc'd my reply to the geotools-gt2-users email list which is
a better forum for questions about how to use gt2.
On Sat, 2004-04-10 at 16:22, femke wrote:
> Hello there,
> I'm casting about for an implementation of "find the nearest spatial
> feature to feature x" query. I poked around the GeoTools API but
> couldn't find what I was after, and was wondering if you could tell me
> whether it is there somewhere or whether you know of any other open
> source Java library that might have it (couldn't find it on JTS).
> I thought I would just check before writing it myself.