Keep coordinates information while converting .dwg to .tif

I need to convert .dwg files to .tif files to be used on geoserver and then displayed on a map.
But my test show that the localisation information of the .dwg file is lost in the conversion. The result is a plain raster with no location, epsg information.
I’m missing something ? Here is my code:

using (var cadImage = (CadImage)Image.Load(dwgFilePath))
{
// Create TIF export options
var tiffOptions = new TiffOptions(TiffExpectedFormat.TiffLzwRgb)
{
VectorRasterizationOptions = new CadRasterizationOptions
{
PageWidth = width,
PageHeight = height,
DrawType = CadDrawTypeMode.UseObjectColor,
ScaleMethod = ScaleType.GrowToFit,

         // Background color
         BackgroundColor = Color.White,

         // High quality rendering
         GraphicsOptions = new GraphicsOptions
         {
             TextRenderingHint = TextRenderingHint.AntiAlias,
             SmoothingMode = SmoothingMode.HighQuality,
             InterpolationMode = InterpolationMode.HighQualityBicubic
         }
     }
 };
 cadImage.Save(outputTifPath, tiffOptions);

}

@JPhil

To retain the coordinate information while converting DWG files to TIFF, it is essential to ensure that the output format supports geospatial metadata. The default TIFF export options in your current implementation may not include this geospatial information, which is the root cause of the issue.

Solution: Follow these steps to address the problem effectively:

  1. Check for Geospatial Support: Confirm that the TIFF format you are using supports geospatial metadata. You may need to utilize a specific library or tool designed for handling geospatial data.

  2. Use the Correct Options: When configuring your TiffOptions, ensure that you include any necessary parameters that allow for the inclusion of geospatial data. This may involve selecting a different set of options or an alternative export method.

  3. Verify Input DWG File: Make sure that the DWG file you are converting contains the required geospatial information. If the original file lacks this data, it will not be present in the output.

  4. Consider Alternative Libraries: If Aspose.CAD does not support the necessary geospatial features, explore other libraries or tools that specialize in geospatial data handling.

Next Steps: Here’s a minimal code snippet to ensure you are using the correct options:

using (var cadImage = (CadImage)Image.Load(dwgFilePath))
{
    var tiffOptions = new TiffOptions(TiffExpectedFormat.TiffLzwRgb)
    {
        VectorRasterizationOptions = new CadRasterizationOptions
        {
            PageWidth = width,
            PageHeight = height,
            DrawType = CadDrawTypeMode.UseObjectColor,
            ScaleMethod = ScaleType.GrowToFit,
            BackgroundColor = Color.White,
            GraphicsOptions = new GraphicsOptions
            {
                TextRenderingHint = TextRenderingHint.AntiAlias,
                SmoothingMode = SmoothingMode.HighQuality,
                InterpolationMode = InterpolationMode.HighQualityBicubic
            }
        }
    };

    // Ensure to check if geospatial options are available
    // Add any geospatial metadata handling here if supported

    cadImage.Save(outputTifPath, tiffOptions);
}

Make sure to consult the documentation for any additional parameters that might be necessary for geospatial data handling. If you have any further questions or need additional assistance, please let me know!

This automatic response is not really helping

@JPhil,
Hi,
could you pelase provide more details and attach initiail DWG and result TIFF, so we can see what is incorrect exactly.