Hi all,
I would like to read the data from a shapefile and convert it to other
format. Here is my code:
int ii = 0;
Iterator iterator = collection.iterator();
try {
while (iterator.hasNext()) {
Feature feature = (Feature) iterator.next();
System.out.print(feature.getID() + "\t");
Fileout.print(ii + " - " + feature.getID() + "\t");
ii++;
for (int i = 0; i < feature.getNumberOfAttributes(); i++) {
Object attribute = feature.getAttribute(i);
if (!(attribute instanceof Geometry)){
System.out.print(attribute + "\t");
Fileout.print(attribute + "\t");
}
else System.out.print("Geometry \t");
}
System.out.println();
Fileout.println();
}
} finally {
collection.close(iterator);
Fileout.close();
}
And the output of the code above has the format:
gt_bd MULTIPOLYGON (((105.82566795385466 21.036750413334275, ……………………)))
0.0 0.0010 2 §êng Ng• 4 Hïng V¬ng - TrÇn Phó
§êng 0.0 0.0 0 0.0 0.0 5 true
But I am interested only in the point value (((105.82566795385466
21.036750413334275, ……………………))) which can obtain by the code: Object
attribute = feature.getAttribute(i); The Object is very general. Can I use
other object that I can obtain the data separably, for example:
pointAttribute = feature.getAttribute(i).getPoint(); // get the points only
otherAttribute = feature.getAttribute(i).getName(); // get other attributes
……………………………….
Thanks,
--
View this message in context:
http://www.nabble.com/convert-shapefile-to-other-format-tf3939203.html#a11172492
Sent from the geotools-gt2-users mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users