java - 在java中绘制一个shapefile

标签 java shapefile

我想用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/

相关文章:

java - 带有 openmap 的 shapefile

python - 如何使用python dxfwrite绘制六边形形状

java - 从模式中提取单词

r - 如何从人口普查形状文件(邮政编码级别)中删除所有小岛?

java - Geoserver 是否不允许跨域数据访问(getFeatureInfo)?

java - 如何以编程方式打印 Jasper 报告

java - 有谁知道可以解析 ESRI Shapefile 的 Java 库?

Java 使用 TransactionManager 实现两阶段提交

java - NetBeans : diamond operator is not supported in -source 1. 5(使用 -source 7 或更高版本启用菱形运算符)

java - 如何通过 CoreNLP 识别小写的命名实体,例如 kobe bryant?