Raster Transformation with VBA

Hallo,

I have a job of transforming 15.000 Geotiff-files from one coordinate system to another (UTM to Gauss-Krüger). I can do it in (Descartes)Connect with attaching all files, manually changing the GCS for each file and then saving them with resampling and reprojecting, but I want to do it without interaction (and faster). In MicroStation VBA I can read the raster attachments, browse through the files and read the geographic information.

Since the geotiff contains no GCS, the identifier is always 0. The image is in my Gauss-Krüger-baesd DGN-file in the "wronG" location at the UTM-coordinates of the image file.

When I start to set the GCS I have differences between V8i and Connect. In V8i I set the GeoTiffProjectionCS value and the image is transfered to the correct location in the graphics and with the next check the GeoTiffProjectionCS value is stored, but the saved Origin remains in the original position. In Connect the setting of the GeoTiffProjectionsCS does nothing. When I check the GeoTiffProjectionCS it remains 0. So my first question is: What is wrong?

Next part in the workflow would be saving the image. The manual "Save as" in Connect works with the resampling and reprojecting options. When I call the saveas in VBA, I have only the resampling option, no reprojecting, so the file is saved with the original  coordinates. Is the reprojection option not available in VBA? If si, is there a workaround?

Third question: Where can I find a list for the values of the geoTiffProjectionCS?

If the way of VBA don't work, has anyone an idea to solve the problem without handling file by file?

Thanks and best regards

Steffen Roemer

VBA Code

Dim TheRasters As Rasters
Dim oRaster As raster
Dim oGeo As GeoReferenceInformation
Private Sub cmdScan_Click()
  Set TheRasters = RasterManager.Rasters
  lstImage.Clear
  For Each oRaster In TheRasters
    lstImage.AddItem oRaster.RasterInformation.Name
  Next
End Sub

Private Sub CommandButton1_Click() 'Setting New GCS - works in V81, not in Connect
Dim i As Long
Dim iGCS As Long
Dim P As Point3d
  i = lstImage.ListIndex + 1
  Set oRaster = TheRasters(i)
  Label1.Caption = oRaster.RasterInformation.Name
  Set oGeo = oRaster.GeoReferenceInformation
  oGeo.GeotiffProjectionCS = 25832
  iGCS = oGeo.GeotiffProjectionCS
  Label2.Caption = iGCS
  P = oGeo.Origin
  Label3.Caption = Format(P.X, "#######0.00") & ", " & Format(P.Y, "######0.00")
End Sub

Private Sub lstImage_Change() 'Checking Image Properties
Dim i As Long
Dim iGCS As Long
Dim P As Point3d
  i = lstImage.ListIndex + 1
  Set oRaster = TheRasters(i)
  Label1.Caption = oRaster.RasterInformation.Name
  Set oGeo = oRaster.GeoReferenceInformation
  iGCS = oGeo.GeotiffProjectionCS
  Label2.Caption = iGCS
  P = oGeo.Origin
  Label3.Caption = Format(P.X, "#######0.00") & ", " & Format(P.Y, "######0.00")
End Sub

  • Hallo,

    ich habe an anderer Stelle dasselbe Problem. Nach Auskunft Bentley wurde die Funktion GeotiffProjectionCS deaktiviert (ohne die Dokumentation anzupassen). Es soll wohl so sein, dass für die Raster eine neue API hinterlegt wurde. Unter Update 7 habe ich bereits einen nachvollziehbaren Fehler zu der Funktion an Bentley gemeldet. In der Konsequenz wurde die Funktion nicht korrigiert, sondern so geschrieben, dass sie immer 0 als Ergebnis liefert (obsolet geschaltet). Eine Intervention bei Bentley liegt vor, wird aber (sehr lange) dauern.

    Als Alternative bleibt nur die Umstellung unter V8i zu machen, so lange diese Version noch funktioniert. 

     

    viele Grüße

     

     

    Uwe