Geotools中读取shapefile路网数据,并创建DirectedGraph
记录一下如何创建DirectedGraph,便于以后查找使用
static ShapefileDataStore sds= null;
static DirectedGraph graph = null;
ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
try {
sds = (ShapefileDataStore)dataStoreFactory.createDataStore(new File("E://桌面//route_LI.shp").toURI().toURL());
} catch (IOException e) {
e.printStackTrace();
}
//设置编码
Charset charset = Charset.forName("GBK");
sds.setCharset(charset);
String typeName = null;
try {
typeName = sds.getTypeNames()[0];
} catch (IOException e) {
e.printStackTrace();
} FeatureSource featureSource = null;
try {
featureSource = sds.getFeatureSource (typeName);
} catch (IOException e) {
e.printStackTrace();
} SimpleFeatureCollection fCollection =null;
try {
fCollection = (SimpleFeatureCollection) featureSource.getFeatures();
} catch (IOException e1) {
e1.printStackTrace();
} DirectedLineStringGraphGenerator lineStringGen = new DirectedLineStringGraphGenerator();
FeatureGraphGenerator featureGen = new FeatureGraphGenerator(lineStringGen);
featureGen.setGraphBuilder(new BasicDirectedLineGraphBuilder());
SimpleFeatureIterator iterator = fCollection.features();
try {
while (iterator.hasNext()) {
SimpleFeature feature = iterator.next();
featureGen.add(feature);
}
} finally {
iterator.close();
}
sds.dispose();
graph = (DirectedGraph)featureGen.getGraph();
Geotools中读取shapefile路网数据,并创建DirectedGraph的更多相关文章
- 从PCD文件中读取点云数据
博客转载自:http://www.pclcn.org/study/shownews.php?lang=cn&id=84 在本小节我们学习如何从PCD文件中读取点云数据. 代码 章例1文件夹中, ...
- nodeks —— fs模块 —— 从流中 读取和写入数据
Fs流读取和写入数据 使用文件流来读取大文件不会卡顿 1, 从流中读取数据 var fs = require("fs"); var data = ''; var count = 0 ...
- 一些常用的文本文件格式(TXT,JSON,CSV)以及如何从这些文件中读取和写入数据
TXT文件: txt是微软在操作系统上附带的一种文本格式,文件以.txt为后缀. 从txt文件中读取数据: with open ('xxx.txt') as file: data=file.readl ...
- Geotools在shapefile路网数据中建立缓冲区,并获取缓冲区内的要素
记录一下如何创建创建缓冲区并获取缓冲区内的要素,便于以后查找使用 static SimpleFeatureSource featureSource = null; static CoordinateR ...
- C#中Form窗体中读取EXCEL的数据
使用OLEDB可以对excel文件进行读取,我们只要把该excel文件作为数据源即可 首先引用Microsoft.EXEL 代码如下: using System; using System.Colle ...
- js中读取解析json数据
在数据传输流程中,json是以文本,即字符串的形式传递的,而JS操作的是JSON对象,所以,JSON对象和JSON字符串之间的相互转换是关键. JSON字符串: 'var str1 = ' ...
- c语言链表从本地文件中读取和写入数据
1 typedef struct Data{ 2 40 char *name; 3 41 char *IDCARD; 4 42 char *job_id; 5 43 char *length; 6 4 ...
- pb中读取大文本数据
string ls_FileName,lb_FileDatas,lb_FileData long ll_FileLen,ll_Handle,ll_Loop,ll_Bytes,ll_Loops,ll_ ...
- Geotools求shapefile路网中任意两点之间最短路径的距离
前言:之前在博问求助过这个问题.经过几天的思考,算是解决了(但仍有不足),另一方面对Geotools不是很熟,有些描述可能不正确,希望大家批评指正. 问题:作为一个新手,我并没有发现Geotools中 ...
随机推荐
- OpenCV 输入输出XML和YAML文件
#include <opencv2/core/core.hpp> #include <iostream> #include <string> using names ...
- spring学习笔记一:spring介绍
jar包下载地址:http://repo.spring.io/release/org/springframework/spring/ spring特点: 1.非侵入性 spring框架的API不会在业 ...
- input系统——android input系统
AndroidInput系统--JNI NativeInputManager InputManger InputReader AndroidInput系统--InputReader AndroidIn ...
- 从又一家外卖被Uber收购,看美团打车未来
别以为Uber在中国失利,连优步中国都被滴滴收购了,就认为Uber已经不行了.其实从全球范围内来看,Uber还是相当强势的--创始人的那些破事儿不算在内.此外,更重要的是Uber已经不单单是在打车业务 ...
- 编程语言十万个为什么之java web的基础概念
1.什么是JAVA Java是一种可以撰写跨平台应用软件的面向对象的程序设计语言,是由SunMicrosystems公司于1995年5月推出的Java程序设计语言和Java平台(即JavaSE, Ja ...
- ubuntu采用apt方式安装多个版本php-fpm
适用系统:Ubuntu 16.04 LTS / Ubuntu 14.04 LTS 安装 PHP Ondřej Surý 的 PHP PPA 为 Ubuntu 16.04/14.04 提供了 PHP7. ...
- 两篇很好的EPG相关文章
两篇很好的EPG相关文章 原文地址:http://blog.sina.com.cn/s/blog_53220cef0100pi8j.html 1 基于DVB-SI的数字有线电视机顶盒节目指南的设计实现 ...
- 通过IE私有滤镜让IE6 7 8支持背景透明,内容不透明效果。
CSS3已经支持背景rgba的rgba透明度,这一方法可以避免元素内容也随背景一起变透明(详情请阅http://www.cssha.com/css3-new-knowledge-student).但是 ...
- NIPS 2016:普及机器学习
2016:普及机器学习" title="NIPS 2016:普及机器学习"> 左起:微软研究员Robert Schapire,John Langford,Al ...
- GIT 使用(二):创建仓库并提交代码
基本操作 所用命令使用 windows 下安装 git-bash 运行 Table of Contents 先决条件 已经安装了 GIT 客户端 已经设置用户信息 如果没做可以看安装和配置 获取 Gi ...