Hi,

I have Shapefile that consists of 33-polygons. I want to convert it to
Array of Arrays - i.e. one big array of the whole shapefile; which contain
33-arrays of *X & Y* coordinates of polygon vertices.

I am thinking of using the java arraylists. Please find the code below :


*Java code*

File file = new File(fName);
        FileDataStore store;
        store = FileDataStoreFinder.getDataStore(file);
        SimpleFeatureSource featureSource = store.getFeatureSource();
        Filter filter = Filter.INCLUDE; // ECQL.toFilter("BBOX(THE_GEOM,
10,20,30,40)")
        collection = featureSource.getFeatures(filter);
        FeatureIterator iterator;
        iterator = collection.features();
    try {
        id = 1;
        while (iterator.hasNext()) {
            Feature feature = iterator.next();
            geom = (Geometry)
feature.getDefaultGeometryProperty().getValue();
            Nvertices = geom.getCoordinates().length;
            System.out.println("No. of vertices" + " " + Nvertices);
            for (int i = 0; i < Nvertices; i++) {
                System.out.println( "x= " + "  " +
geom.getCoordinates()[i].x + "  " + "y= " + "  " +
geom.getCoordinates()[i].y);
                }
            //Nvertices = geom.getNumPoints();

         id++;
        }
    }
    finally {
        iterator.close();
    }
    }



Your help is appreciated.

Best wishes,
Ahmed
------------------------------------------------------------------------------
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to