package com.test.geotools.shp;
import java.io.File;
import java.io.IOException;
import java.net.MalformedURLException;
import org.geotools.data.FeatureSource;
import org.geotools.data.shapefile.ShapefileDataStore;
import org.geotools.feature.FeatureCollection;
import org.geotools.feature.FeatureIterator;
import org.opengis.feature.simple.SimpleFeature;
import org.opengis.feature.simple.SimpleFeatureType;
import com.vividsolutions.jts.geom.Geometry;
public class shptest {
public static void main(String[] argv){
String strShpPath = "D:\\data\\country.shp";
File file = new File(strShpPath);
ShapefileDataStore shpDataStore = null;
try{
shpDataStore = new ShapefileDataStore(file.toURL());
String typeName = shpDataStore.getTypeNames()[0];
FeatureSource<SimpleFeatureType, SimpleFeature> featureSource = null;
featureSource = (FeatureSource<SimpleFeatureType, SimpleFeature>)shpDataStore.getFeatureSource(typeName);
FeatureCollection<SimpleFeatureType, SimpleFeature> result = featureSource.getFeatures();
FeatureIterator<SimpleFeature> itertor = result.features();
while(itertor.hasNext()){
SimpleFeature feature = itertor.next();
Geometry geometry = (Geometry)feature.getDefaultGeometry();
System.out.println(geometry.toText());
}
itertor.close();
}
catch(MalformedURLException e){
e.printStackTrace();
}
catch(IOException e){
e.printStackTrace();
}
}
}
分享到:
相关推荐
NULL 博文链接:https://javaeye-hua.iteye.com/blog/1009362
org.geotools.data.vpf.file org.geotools.data.vpf.ifc org.geotools.data.vpf.io org.geotools.data.vpf.readers org.geotools.data.vpf.util org.geotools.data.wfs org.geotools.data.wms org.geotools....
geotools对wms的实现支持,给出了geotools如何开发一个简单的wms实现,对理解geoserver源码有很大的帮助作用。
geotools读取shp文件及shp文件操作工具类代码.pdf
根据java的geotools库,对shape进行操作,实现以下功能: 1、读取shape属性 2、另存新shape文件 3、shape中新增字段 4、JavaFx实现页面
// display a data store file chooser dialog for shapefiles File file = JFileDataStoreChooser.showOpenFile("shp", null); if (file == null) { return; } FileDataStore store = ...
org.geotools org.geotools.arcsde org.geotools.arcsde.data org.geotools.arcsde.data.view org.geotools.arcsde.filter org.geotools.arcsde.jndi org.geotools.arcsde.logging org.geotools.arcsde....
java+GeoTools搭建第一个GeoToolsDemo,读取shape格式文件。此zip为官网示例文件
GeoTools是一个开源的Java库,提供地理空间数据工具
geotools汉语版资料
英文版本,不是中文版本的 GeoTools开发的工具
NULL 博文链接:https://jjxliu306.iteye.com/blog/2423964
geotools依赖包
geotools所需jar包合集,内含4个geotools的jar包,各位可以根据需要自行导入使用,预祝bug少少
springboot项目-基于geotools的倾斜摄影大地坐标转自定义投影坐标源码.zipspringboot项目-基于geotools的倾斜摄影大地坐标转自定义投影坐标源码.zipspringboot项目-基于geotools的倾斜摄影大地坐标转自定义投影坐标...
geotools 判断几何要素的交点 当时想到用的GDAL 但是 交点函数返回的对象总是null , 改用 GeoTools 这个库,需要用到jar 到官网上下载,主要是jts-core-1.16.0.jar
geotools学习(一)IntelliJ IDEA搭建快速入门示例.pdf