I'm used the GDAL to modify the coordinates of polygons. I have referenced the C++ and Python versions of the code and modified them in Java:
String ShpPath="G:\\GeoData\\New_Shapefile.shp";
DataSource dataSource=ogr.Open(ShpPath,1);
Layer layer=dataSource.GetLayer(0);
System.out.println(layer.GetFeatureCount());
Feature feature;
while ((feature=layer.GetNextFeature())!=null)
{
Geometry geometry = feature.GetGeometryRef();
Geometry geo2=geometry.GetGeometryRef(0);
for (int j = 0; j < geo2.GetPointCount(); j++)
{
System.out.println("X:"+geo2.GetX(j)+" Y:"+geo2.GetY(j));
geo2.SetPoint(j,geo2.GetX(j)+1,geo2.GetY(j)+1);
}
feature.SetGeometry(geometry);
layer.SetFeature(feature);
}
But when I'm done, I load the data into Arcmap and a warning is displayed:
Acope inconsistent! The scope of one or more added layers is inconsistent with the associated spatial reference information.
How can I solve this problem?