Gdal analysis (1) Reading raster data to Dataset

Source: Internet
Author: User

Process Analysis of gdal reading Raster Data
Today, we use gdal to write a demo to read raster data and display its band, color, and other information.
Here, I will share with you an analysis of how gdal reads raster data.

1. The first step to use gdal is to register it first. Use the static function gdal. allregister ();
2. gdal reads all the raster data to a custom dataset. Therefore, osgeo. gdal. dataset DS = new osgeo. gdal. dataset ();
3. Use the OPEN function DS = gdal. Open (inputfilename, gdalconst. ga_readonly );
4. Now, the grid file with the full path of inputfilename has been read to DS. The osgeo. gdal. dataset class is introduced below.
In general, osgeo. gdal. dataset is actually a combination of a series of associated bands.
Its members are as follows:

Virtual ~ Gdaldataset ()
Int getrasterxsize (void)
Int getrasterysize (void)
Int getrastercount (void)
Gdalrasterband * getrasterband (INT)
Virtual void flushcache (void)
Virtual const char * getprojectionref (void)
Virtual cplerr setprojection (const char *)
Virtual cplerr getgeotransform (double *)
Virtual cplerr setgeotransform (double *)
Virtual cplerr addband (gdaldatatype etype, char ** papszoptions = NULL)
Virtual void * getinternalhandle (const char *)
Virtual gdaldriver * getdriver (void)
Virtual int getgcpcount ()
Virtual const char * getgcpprojection ()
Virtual const gdal_gcp * getgcps ()
Virtual cplerr setgcps (INT ngcpcount, const gdal_gcp * pasgcplist, const char * pszgcpprojection)
Virtual cplerr adviseread (INT nxoff, int nyoff, int nxsize, int nysize, int nbufxsize, int nbufysize, gdaldatatype EDT, int nbandcount, int * panbandlist, char ** papszoptions)
Cplerr rasterio (gdalrwflag, Int, void *, Int, Int, gdaldatatype, Int, int *, Int, INT)
Int reference ()
Int dereference ()
Gdalaccess getaccess ()
Int getshared ()
Void markasshared ()
Cplerr buildoverviews (const char *, Int, int *, Int, int *, gdalprogressfunc, void *)

AboveCodeIt is a C language with a rather annoying pointer. However, as long as you think carefully, you can easily convert it into a C # language.
5. The following methods are commonly used.

Obtain the driver. For example, the driver for the tif file is geotiff.
Virtual gdaldriver * getdriver (void)

Obtain the projection method. In. net, the return value is a string-type projection description statement.
Virtual const char * getprojectionref (void)

 

Obtains the number of bands. This value determines the number of cycles for each band.

Int getrastercount (void)

For (INT iband = 1; iband <= Ds. rastercount; iband ++)
{
Band band = Ds. getrasterband (iband); // obtain the specified band
}

Int getrasterxsize (void)
Int getrasterysize (void)
Obtains the size of a band.
Last one:

Cplerr buildoverviews (const char *, Int, int *, Int, int *, gdalprogressfunc, void *)

This is to build overviews on DS. I guess it is to create a pyramid-like extraction or view. I am still exploring. Hope you can advise me!

6. This time we will first study the band. Next time we will start with the band and continue to explore.

The demo is as follows:

--

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.