QGIS
简介
(原称Quantum GIS),是一个桌面地理信息系统,可运行在Linux、Unix、Mac OSX和Windows等平台之上。QGIS是基于Qt,使用C++开发的。
支持栅格(raster)和矢量(vector)两种图像,前者主要包括GeoTIFF、JPEG、PNG等文件格式,后者以点、折线和多边形三种要素(feature)的形式进行存储,既可以是文件,也可以是数据库。
栅格图即是点阵图,用于展示卫星遥感、土地利用、温度分布等直观影像。矢量图通常用于展示人为划分的功能性逻辑区域,比如用点表示城市、机场、加油站等不同级别的地点信息,用折线表示道路、河流等线型信息,用多边形表示湖泊、各类用地等区域信息。
存储地理空间数据的数据库,称为空间数据库。QGIS支持与Oracle Spatial、SQL Server、MySQL、PostgreSQL等多种主流数据库连接,其中PostgreSQL为QGIS的主打数据库。
导出带有坐标的文件
导出jgons格式或者csv格式,之后选择wkt
jgson格式转WKT格式
jgson的格式
{"type":"Polygon","coordinates":[[[67.406616,31.219848],[66.968536,31.312582],[66.386261,30.934035],[66.246185,29.851364],[65.066528,29.536424],[64.487,29.572263],[64.105225,29.377388],[63.59024,29.491011],[62.455902,29.389355],[60.877991,29.862083],[61.846161,31.041168],[61.712952,31.375917],[60.857391,31.49192],[60.876617,32.198857],[60.58548,33.143301],[60.945282,33.494453],[60.643158,33.564284],[60.478363,34.078825],[60.69397,34.311681],[60.917816,34.301472],[60.746155,34.52353],[60.997467,34.632078],[61.276245,35.612651],[61.600342,35.436058],[62.057648,35.437177],[62.302094,35.141248],[62.748413,35.264683],[63.095856,35.428225],[63.248291,35.691879],[63.128815,35.869021],[64.065399,36.001341],[64.448547,36.23652],[64.756165,37.10667],[65.523834,37.234702],[65.765533,37.544577],[66.31073,37.319936],[66.971283,37.386526],[67.2789,37.18439],[67.752686,37.2183],[68.005371,36.929037],[68.89801,37.330857],[69.266052,37.101194],[69.455566,37.231422],[69.367676,37.406165],[69.532471,37.590295],[70.168304,37.529332],[70.305634,37.694688],[70.179291,37.944198],[70.677795,38.40733],[70.989532,38.483695],[71.358948,38.258671],[71.249084,37.925784],[71.584167,37.919284],[71.426239,37.057369],[71.661072,36.679433],[72.670441,37.021195],[73.309021,37.462869],[73.762207,37.432341],[73.612518,37.27296],[73.745728,37.222674],[74.235992,37.414891],[74.829254,37.328673],[74.878693,37.223768],[74.477692,37.199706],[74.558716,36.959768],[74.053345,36.829073],[72.631989,36.848857],[72.241974,36.753189],[71.857452,36.399178],[71.636353,36.472098],[71.199646,36.045768],[71.547089,35.719758],[71.674805,35.196256],[70.995026,34.555204],[71.170807,34.358175],[71.07605,34.062899],[70.502014,33.94336],[69.897766,34.027624],[70.323486,33.330528],[69.507751,33.02939],[69.451447,32.663656],[69.241333,32.461109],[69.318237,31.927689],[68.900757,31.600762],[68.569794,31.827399],[68.432465,31.763202],[68.536835,31.714149],[68.168793,31.834399],[67.553558,31.529385],[67.789764,31.357155],[67.406616,31.219848]]]}
wkt格式
POLYGON ((67.406616 31.219848, 66.968536 31.312582, 66.386261 30.934035, 66.246185 29.851364, 65.066528 29.536424, 64.487 29.572263, 64.105225 29.377388, 63.59024 29.491011, 62.455902 29.389355, 60.877991 29.862083, 61.846161 31.041168, 61.712952 31.375917, 60.857391 31.49192, 60.876617 32.198857, 60.58548 33.143301, 60.945282 33.494453, 60.643158 33.564284, 60.478363 34.078825, 60.69397 34.311681, 60.917816 34.301472, 60.746155 34.52353, 60.997467 34.632078, 61.276245 35.612651, 61.600342 35.436058, 62.057648 35.437177, 62.302094 35.141248, 62.748413 35.264683, 63.095856 35.428225, 63.248291 35.691879, 63.128815 35.869021, 64.065399 36.001341, 64.448547 36.23652, 64.756165 37.10667, 65.523834 37.234702, 65.765533 37.544577, 66.31073 37.319936, 66.971283 37.386526, 67.2789 37.18439, 67.752686 37.2183, 68.005371 36.929037, 68.89801 37.330857, 69.266052 37.101194, 69.455566 37.231422, 69.367676 37.406165, 69.532471 37.590295, 70.168304 37.529332, 70.305634 37.694688, 70.179291 37.944198, 70.677795 38.40733, 70.989532 38.483695, 71.358948 38.258671, 71.249084 37.925784, 71.584167 37.919284, 71.426239 37.057369, 71.661072 36.679433, 72.670441 37.021195, 73.309021 37.462869, 73.762207 37.432341, 73.612518 37.27296, 73.745728 37.222674, 74.235992 37.414891, 74.829254 37.328673, 74.878693 37.223768, 74.477692 37.199706, 74.558716 36.959768, 74.053345 36.829073, 72.631989 36.848857, 72.241974 36.753189, 71.857452 36.399178, 71.636353 36.472098, 71.199646 36.045768, 71.547089 35.719758, 71.674805 35.196256, 70.995026 34.555204, 71.170807 34.358175, 71.07605 34.062899, 70.502014 33.94336, 69.897766 34.027624, 70.323486 33.330528, 69.507751 33.02939, 69.451447 32.663656, 69.241333 32.461109, 69.318237 31.927689, 68.900757 31.600762, 68.569794 31.827399, 68.432465 31.763202, 68.536835 31.714149, 68.168793 31.834399, 67.553558 31.529385, 67.789764 31.357155, 67.406616 31.219848))
实现
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-shapefile</artifactId>
<version>19.2</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-swing</artifactId>
<version>19.2</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-jdbc</artifactId>
<version>19.2</version>
</dependency>
<dependency>
<groupId>org.geotools.jdbc</groupId>
<artifactId>gt-jdbc-postgis</artifactId>
<version>19.2</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-epsg-hsql</artifactId>
<version>19.2</version>
</dependency>
<dependency>
<groupId>org.geotools</groupId>
<artifactId>gt-geojson</artifactId>
<version>12.0</version>
</dependency>
<dependency>
<groupId>com.vividsolutions</groupId>
<artifactId>jts</artifactId>
<version>1.13</version> <!--2-->
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
public static String wktToJson(String wkt) {
String json = null;
try {
WKTReader reader = new WKTReader();
Geometry geometry = reader.read(wkt);
StringWriter writer = new StringWriter();
GeometryJSON g = new GeometryJSON(20);
g.write(geometry, writer);
json = writer.toString();
} catch (Exception e) {
e.printStackTrace();
}
return json;
}
public static String jsonToWkt(JSONObject jsonObject) {
String wkt = null;
String type = jsonObject.getString("type");
GeometryJSON gJson = new GeometryJSON();
try {
Reader reader = GeoJSONUtil.toReader(jsonObject.toString());
Geometry read = gJson.read(reader);
wkt = read.toText();
} catch (IOException e) {
System.out.println("GeoJson转WKT出现异常");
e.printStackTrace();
}
return wkt;
}
@RequestMapping(value = "/text", method = RequestMethod.POST)
public String text(@RequestBody Object geom) {
JSONObject jsonObject = JSONObject.parseObject(JSON.toJSONString(geom));
return WKTutil.jsonToWkt(jsonObject);
}

浙公网安备 33010602011771号