有没有人知道Java中的库可以解析ESRI Shapefiles?

Kin*_*tor 49 java shapefile geotools

我有兴趣为2009年Tiger/Line Shapefiles中的道路数据编写可视化程序.我想绘制线数据来显示我县的所有道路.

ESRI Shapefile或简单的shapefile是用于地理信息系统软件的流行的地理空间矢量数据格式.它由ESRI开发和监管,作为ESRI和其他软件产品之间数据互操作性的(主要)开放式规范.1 "shapefile"通常是指带有".shp",".shx",".dbf"的文件集合,以及公共前缀名称上的其他扩展名(例如"lakes.*").实际的shapefile特别涉及具有".shp"扩展名的文件,但是这个文件本身不完整,因为需要其他支持文件.

有没有人知道用于解析和读取Shapefiles的行数据的现有库?

Cli*_*int 63

GeoTools会做到这一点.有大量的罐子,你不需要大多数罐子.但是,读取shapefile只需几行.

File file = new File("mayshapefile.shp");

try {
  Map<String, String> connect = new HashMap();
  connect.put("url", file.toURI().toString());

  DataStore dataStore = DataStoreFinder.getDataStore(connect);
  String[] typeNames = dataStore.getTypeNames();
  String typeName = typeNames[0];

  System.out.println("Reading content " + typeName);

  FeatureSource featureSource = dataStore.getFeatureSource(typeName);
  FeatureCollection collection = featureSource.getFeatures();
  FeatureIterator iterator = collection.features();


  try {
    while (iterator.hasNext()) {
      Feature feature = iterator.next();
      GeometryAttribute sourceGeometry = feature.getDefaultGeometryProperty();
    }
  } finally {
    iterator.close();
  }

} catch (Throwable e) {}
Run Code Online (Sandbox Code Playgroud)

  • 如果您使用Maven编译程序,它会为您处理所有的jar. (3认同)
  • Geotools 有关于如何开始开发的精彩教程。这是一个用于可视化地图的 Swing 应用程序 http://docs.geotools.org/latest/userguide/tutorial/quickstart/netbeans.html (2认同)

Rob*_*tie 8

Openmap有一个Java API,提供对ESRI文件的读写访问.


adr*_*rau 5

GeoTools,或者更确切地说是这个类ShapefileDataStore.