Dashboard > UDIG Developer Guide > Home > 5 FAQ > GIS Application Questions > How to get geometries from layer
How to get geometries from layer Log In | Sign Up   View a printable version of the current page.

Added by cedric , last edited by cedric on Jan 30, 2006
Labels: 
(None)

Q: How to get geometries from layer

To get geometries from a layer you need to ask for a FeatureSource object from the layer:

FeatureSource source=layer.getResource( FeatureSource.class, progressMonitor);

(You need the org.geotools.feature.FeatureSource class). Once you have a feature source you can get all the features from the source by:

FeatureCollection collection=source.getFeatures();

It is a feature collect and has all the normal collection methods.

WARNING: don't forget to close your iterator after using one:

collections.close(iterator);
Powered by a free Atlassian Confluence Open Source Project License granted to uDig. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7.1, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators
User-friendly Desktop Internet GIS