我想用java读取一个shapefile,然后绘制它。有没有办法读取shapefile并用java绘制它?你知道什么有用且简单的框架吗?
谢谢。
最佳答案
您可以尝试Geotools 。您可以从这段代码开始。
public class Quickstart {
public static void main(String[] args) throws Exception {
File file = JFileDataStoreChooser.showOpenFile("shp", null);
if (file == null) {
return;
}
FileDataStore store = FileDataStoreFinder.getDataStore(file);
SimpleFeatureSource featureSource = store.getFeatureSource();
// Create a map content and add our shapefile to it
MapContent map = new MapContent();
map.setTitle("Quickstart");
Style style = SLD.createSimpleStyle(featureSource.getSchema());
Layer layer = new FeatureLayer(featureSource, style);
map.addLayer(layer);
// Display the map
JMapFrame.showMap(map);
}
}
关于java - 在java中绘制一个shapefile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29930647/