【发布时间】:2020-11-25 09:42:19
【问题描述】:
我是 Geotools 的新手。现在我想在奥地利的 Shapefile 中插入一个自定义区域(多边形)。 我的代码:
public static void main(String[] args) throws IOException {
File file = new File("src/main/java/org/geotools/austria.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);
MapContent showmap = new MapContent();
showmap.setTitle("Austria");
Style style = SLD.createSimpleStyle(source.getSchema());
Layer layer = new FeatureLayer(source, style);
showmap.addLayer(layer);
// display the map
JMapFrame.showMap(showmap);
}
我目前的结果:
这张图片显示了我当前的输出。我画了一个红色的六边形来展示我将来想要的东西。 如何将此多边形插入并显示到 Shapefile 中?
【问题讨论】:
标签: java shapefile geo geotools