Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a shapefile with some polygons. I would like to change the height for this elements using Java. The rest of the attributes should be the same. I've thought using GeoTools but I haven't found how to implement this.

Any help?

Thanks in advance

share|improve this question

The following is assuming that you know how to read and write a FeatureCollection in geotools.

SimpleFeatureCollection inVector = "read it"
SimpleFeatureCollection outVector = FeatureCollections.newCollection();
String elevationFieldName = "elev";

int size = inVector.size();
FeatureIterator<SimpleFeature> inFeatureIterator = inVector.features();
while( inFeatureIterator.hasNext() ) {
    SimpleFeature feature =;
    feature.setAttribute(elevationFieldName, yourNewElevation);

Then just write outVector to a new shapefile.

Reading and writing is covered in the tutorials:

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.