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)
| 归档时间: |
|
| 查看次数: |
37508 次 |
| 最近记录: |