[FWTools] DD to UTM conversion in c#

sebastien DECORME sebastien.decorme at survey-copter.com
Thu Dec 3 07:20:19 EST 2009


HI

I want to make Degre to UTM conversion with the OSR/GDAL library (anything
else I’ve no choice) 

I’m looking on the web for 3 days to find a way to make this.

 

I’ve downloaded  the FWtools 2.4.6

I’ve add to my project all the dll in the directory

C:\Program Files\FWTools2.4.6\csharp 

 

I add in the path 

C:\Program Files\FWTools2.4.6\bin 

 

And my very simple test program look like this

 

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms;

using OSGeo.OSR;

 

namespace UTM_GEO

{

    public partial class Form1 : Form

    {

         

        SpatialReference oUTM = new SpatialReference("");

        SpatialReference oWGS = new SpatialReference("");

 

        public Form1()

        {

            InitializeComponent();         

        }

        private int FindUtmZone(double Longitude)

        {

            int retour = -1;

            retour = Convert.ToInt16 ((Longitude - (-180)) / 6 + 1);

            return retour;

        }

        private void BtnToUTM_Click(object sender, EventArgs e)

        {

            double Longitude = Convert.ToDouble(TxtGeoLon.Text);

            int ZoneUTMCourante = FindUtmZone(Longitude);

 

            string NomProj = "UTM " + ZoneUTMCourante.ToString() + " /
WGS84";

 

            oUTM.SetProjCS(NomProj);

            oUTM.SetWellKnownGeogCS( "WGS84" );

        }

    }

}

 

I’ve an error at this line 

SpatialReference oUTM = new SpatialReference("");

 

The type initializer for 'OSGeo.OSR.OsrPINVOKE' threw an exception.". 

The innermost exception is what you'd expect - "System.DllNotFoundException:
Unable to load DLL 
'osr_wrap': The operating system cannot run."

 

I’ve tested this link 

http://n2.nabble.com/using-OGR-OSR-from-C-where-to-put-the-dependent-DLLs-td
2032457.html

 

but it doesn’t work at all.

 

 

Please I need help

 

Thanks

 

Sébastien DECORME

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.maptools.org/pipermail/fwtools/attachments/20091203/a01bf772/attachment.htm 


More information about the FWTools mailing list