GDAL - Transformpoint ArgumenteC#

Ein Treffpunkt für C#-Programmierer
Anonymous
 GDAL - Transformpoint Argumente

Post by Anonymous »

Angesichts des unten stehenden Codes erhalte ich einen Compiler-Fehler < /p>

Keine Überlastung für Methode 'Transformpoint' Nimmt 3 Argumente < /p>
< /blockquote>
Hier ist die tatsächliche Codezeile, die den Fehler: < /p>


Dies ist das, was IntelliSense aus dem Paket zerlegt hat: < /p>
public void TransformPoint(double[] inout)
{
OsrPINVOKE.CoordinateTransformation_TransformPoint__SWIG_0(swigCPtr, inout);

if (OsrPINVOKE.SWIGPendingException.Pending)
{
throw OsrPINVOKE.SWIGPendingException.Retrieve();
}
}

public void TransformPoint(double[] argout, double x, double y, double z)
{
OsrPINVOKE.CoordinateTransformation_TransformPoint__SWIG_2(swigCPtr, argout, x, y, z);

if (OsrPINVOKE.SWIGPendingException.Pending)
{
throw OsrPINVOKE.SWIGPendingException.Retrieve();
}
}

public void TransformPoint(double[] argout, double x, double y, double z, double t)
{
OsrPINVOKE.CoordinateTransformation_TransformPoint__SWIG_3(swigCPtr, argout, x, y, z, t);

if (OsrPINVOKE.SWIGPendingException.Pending)
{
throw OsrPINVOKE.SWIGPendingException.Retrieve();
}
}
< /code>
Mein Code: < /p>
using System;
using System.Collections.Generic;
using System.IO;
using OSGeo.GDAL;
using OSGeo.OSR;

public static void Main()
{
// Register all GDAL drivers
Gdal.AllRegister();

// Define the WKT for NAD83 and NAD27 coordinate systems
string nad83Wkt = @"GEOGCS[""NAD83"",
DATUM[""North_American_Datum_1983"",
SPHEROID[""GRS_1980"",6378137,298.257222101],
AUTHORITY[""EPSG"",""6269""]],
PRIMEM[""Greenwich"",0],
UNIT[""degree"",0.0174532925199433],
AUTHORITY[""EPSG"",""4269""]]";

string nad27Wkt = @"GEOGCS[""NAD27"",
DATUM[""North_American_Datum_1927"",
SPHEROID[""Clarke_1866"",6378206.4,294.978698213898],
AUTHORITY[""EPSG"",""6267""]],
PRIMEM[""Greenwich"",0],
UNIT[""degree"",0.0174532925199433],
AUTHORITY[""EPSG"",""4267""]]";

// Create Spatial Reference objects for NAD83 and NAD27
SpatialReference nad83 = new SpatialReference(nad83Wkt);
SpatialReference nad27 = new SpatialReference(nad27Wkt);

// Create a Coordinate Transformation
CoordinateTransformation transform = new CoordinateTransformation(nad83, nad27);

// Example NAD83 coordinates (longitude, latitude)
double[] nad83Coordinates = new double[] { -101.9296078000, 32.1094884400 }; // Replace with your NAD83 coordinates

// Variables to hold the transformed coordinates
double[] nad27Coordinates = new double[2];

// Perform the transformation to NAD27
transform.TransformPoint(nad27Coordinates, nad83Coordinates[0], nad83Coordinates[1]);

// Output the transformed coordinates
Console.WriteLine($"NAD83 Coordinates: Longitude: {nad83Coordinates[0]}, Latitude: {nad83Coordinates[1]}");
Console.WriteLine($"NAD27 Coordinates: Longitude: {nad27Coordinates[0]:F10}, Latitude: {nad27Coordinates[1]:F10}");

// Cleanup
nad83.Dispose();
nad27.Dispose();
transform.Dispose();

// Example usage:
// ReadXls("your_input_file.xlsx");
// WriteXls("your_output_file.xlsx");
Console.ReadKey();
}
[/code]

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post