我想从数组中的值中画一条线。我有2个数组,即latitude
和longitude
,其中包含值。我想在我的shape文件上绘制一条带有这些值的行。 (" .SHP")使用geotools。
答案 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了解详情。