This is my first time using GeoTools and I have a 3 simple things I need to get from .shp files which I'm reading with my program.
I need to know in specific coordinates (latitude/longitude).
Example: lat=58.85 lon=5.26 for 3 specific things:
- Exclusive Economic Zone (EEZ)
- FAO area
- ICES statistical rectangle
I know that all of these properties are there, because tested the whole shapefile and it gave my these results:
EEZ<EEZ id=eez.232>=German Exclusive Economic Zone
EEZ<EEZ id=eez.233>=Azerbaijanis Exclusive Economic Zone
EEZ<EEZ id=eez.234>=Kazakh Exclusive Economic Zone
And same is for ICES rectangles:
ICESNAME<ICESNAME id=ices.11002>=26M8
ICESNAME<ICESNAME id=ices.11003>=27M8
It reads the whole shapefile, but I don't know how to read these 3 properties from specific coordinate.
My program code:
File file = new File(shapeDirectory + "ices.shp");
Map<String, Object> map = new HashMap<>();
map.put("url", file.toURI().toURL());
DataStore dataStore = DataStoreFinder.getDataStore(map);
String typeName = dataStore.getTypeNames()[0];
FeatureSource<SimpleFeatureType, SimpleFeature> source = dataStore.getFeatureSource(typeName);
Filter filter = Filter.INCLUDE; // ECQL.toFilter("BBOX(THE_GEOM, 10,20,30,40)")
SimpleFeatureType schema = source.getSchema();
String geomType = schema.getGeometryDescriptor().getType().getBinding().getName();
System.out.println(geomType);
FeatureCollection<SimpleFeatureType, SimpleFeature> collection = source.getFeatures(filter);
try (FeatureIterator<SimpleFeature> features = collection.features()) {
while (features.hasNext()) {
SimpleFeature feature = features.next();
System.out.print(feature.getID());
Property property = feature.getProperty("ICESNAME");
System.out.println(property);
}
}
}
How to read all these 3 attributes (from 3 different shape files (fao/ices/eez)) at specific coordinates? The coordinate input will be decimal, but if someone knows, please provide me the degrees/minutes/seconds example too.