在GeoTools中使用纬度经度绘制一条线

时间:2014-09-19 05:49:23

标签: java geotools

我想从数组中的值中画一条线。我有2个数组,即latitudelongitude,其中包含值。我想在我的shape文件上绘制一条带有这些值的行。 (" .SHP")使用geotools。

1 个答案:

答案 0 :(得分:1)

使用以下代码创建POINT,然后创建FeatureCollection,然后创建shapefile:

SimpleFeatureCollection collection = FeatureCollections.newCollection();
GeometryFactory geometryFactory = JTSFactoryFinder.getGeometryFactory();
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(TYPE);
Point point = geometryFactory.createPoint(new Coordinate(longitude, latitude));
featureBuilder.add(point);
SimpleFeature feature = featureBuilder.buildFeature(null);
collection.add(feature);

阅读geoTools feature tutorial了解详情。