Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way to get distinct values from multiple columns in geotools?

I know I can get unique values from a column like this:

SimpleFeatureSource featureSource = dataStore.getFeatureSource(layer);
Query query = new Query(layer, Filter.INCLUDE, new String[] { "PROPERTY_A", 
UniqueVisitor visitor = new UniqueVisitor("PROPERTY_A");
SimpleFeatureCollection collection = featureSource.getFeatures( query );
collection.accepts(visitor, null);
Set set = visitor.getResult()

But what I need is an equivalent to select distinct PROPERTY_A, PROPERTY_B, PROPERTY_C.

Edit: I've tried to get unique values from the first column, and then create cql filters with the unique values from the first column to query unique values from the second column and so on, an then join it all in the end. But the performance, as expected, is very poor.

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.