-
Notifications
You must be signed in to change notification settings - Fork 14
Python API Reproject Feature Coverage
The Python API for IlwisObjects gives you many possibilities to reproject a Feature Coverage:
The simplest way most probably is just using the .reprojectFeatures() function. You only need to give it the CoordinateSystem you want your FeatureCoverage projected to and it will reproject all features from this coverage and will put them back in place. This way the funciton has no extra output but just modifies the already existing coverage.
pointmap = FeatureCoverage("Natuurkalender.shp")
csy = CoordinateSystem('epsg:3035')
pointmap.reprojectFeatures(csy)Another and little bit longer way is to use the .newFeatureFrom() function, which you should call on a new and probably empty FeatureCoverage. The parameters it needs are the feature you want to reproject and the original CoordinateSystem. It will then automatically store a new feature in your new coverage. An important step is to actually assign the new coordinate system to your new coverage, else it won't work because the function doesn't know which coordinate system to project to.
fc = FeatureCoverage("Natuurkalender.shp")
# create a new coordinate system
csynew = CoordinateSystem('epsg:2050')
# create a new and empty FeatureCoverage
newfc = FeatureCoverage()
# give it a coordinate system and a name
newfc.setCoordinateSystem(csynew)
newfc.name(fc.name()+'_2050')
#iterate over the features from the original coverage
for feature in fc:
#call .newFeatureFrom() for every feature
newfc.newFeatureFrom(feature, fc.coordinateSystem())
#set the new feature coverage table from the old one
newfc.setTable(fc.attributeTable())