Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I want to upload a jpeg or some raster image into a C# form and then on entering the latitude and longitudes I need to be able to create an GEOTIFF file of the same image. How can this be done in C#.NET?

you had asked me to use GDAL libraries i did add references, i'm using Visual studio 2010, i have included library files, i have computed llx lly lux luy also, but how to tag it to an image, is there any inbuilt function or anything?

this is the code i have used

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OSGeo.GDAL;
using OSGeo.OGR;
using OSGeo.OSR;

namespace geo_tagging
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            int orx = pictureBox1.Image.Height;
            int ory = pictureBox1.Image.Height;
            int ctrx, ctry, lux, luy, llx, lly, bufx, bufy;
            bufx = orx / 108000;
            bufy = ory / 108000;
            ctrx = int.Parse(textBox2.Text);
            ctry = int.Parse(textBox3.Text);
            lux = ctrx - bufx;
            luy = ctry - bufy;
            llx = ctrx + bufx;
            lly = ctry + bufy;

            Gdal.GCPsToGeoTransform(
        }

        private void button1_Click(object sender, EventArgs e)

        {
            OpenFileDialog dlg = new OpenFileDialog();


            if (dlg.ShowDialog() == DialogResult.OK)
            {                     
            PictureBox PictureBox1 = new PictureBox();
            string Chosen_File = "";
            Chosen_File = dlg.FileName;
            textBox1.Text = dlg.FileName;
            pictureBox1.Image = Image.FromFile(Chosen_File);
            int X = pictureBox1.Image.Height;
            int Y = pictureBox1.Image.Width;
            label2.Text = X.ToString();
            label4.Text = Y.ToString();

            }

            dlg.Dispose();
        }

        private void button3_Click(object sender, EventArgs e)
        {
            textBox1.Text="";
            textBox2.Text="";
            textBox3.Text="";
            pictureBox1.Image.Dispose();

        }

       private void pictureBox1_Click(object sender, EventArgs e)
        {
            OpenFileDialog dlg = new OpenFileDialog();


            if (dlg.ShowDialog() == DialogResult.OK)
            {
                PictureBox PictureBox1 = new PictureBox();
                string Chosen_File = "";
                Chosen_File = dlg.FileName;
                textBox1.Text = dlg.FileName;
                pictureBox1.Image = Image.FromFile(Chosen_File);
                int X = pictureBox1.Image.Height;
                int Y = pictureBox1.Image.Width;
                label2.Text = X.ToString();
                label4.Text = Y.ToString();

            }

            dlg.Dispose();
        }



       private void textBox1_Click(object sender, EventArgs e)
       {
           textBox1.Text = "";
       }

        }
 }

never mind got it guys, we need to use a exe file to call it as a process and pass arguments into it!

thanks for the help

share|improve this question
    
I've fixed up your code's formatting but there are bits missing that you might need to fix before someone can answer the question. –  iant Mar 12 '12 at 13:12
    
Thanks a lot actually this shows the way i'm calculating the latitude and longitude of corners based on the center coordinates given so all i want is a way to generate the geoTiff file by entering the latitude values using any function or library in C# form application Visual Studio 2010, just need help on function. this code is running fine for me but –  gautam Mar 13 '12 at 16:58
add comment

2 Answers 2

The easiest way to continue would be to make a call to gdalwarp. http://www.gdal.org/gdalwarp.html Use the -te option to specify your extent:

-te xmin ymin xmax ymax:

set georeferenced extents of output file to be created
share|improve this answer
    
No like in the Visual Studio C#, do we have any built in function? from where do i call the GDALWRAP –  gautam Mar 12 '12 at 3:23
add comment

does the code at http://www.gdal.org/warptut.html give you any clues? I don't speak C# so I can't tell if it will help or not.

share|improve this answer
    
thanks for the effort cause that is in C++ i want C# so yea..! –  gautam Mar 12 '12 at 14:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.