Created
November 22, 2016 03:38
-
-
Save monkeybutter/769a24bcf87682171eb87ac05c9347c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "gdal.h" | |
#include "ogr_core.h" | |
#include "ogr_srs_api.h" | |
#include "cpl_conv.h" | |
#include <assert.h> | |
char *WGS84WKT = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0,AUTHORITY[\"EPSG\",\"8901\"]],UNIT[\"degree\",0.01745329251994328,AUTHORITY[\"EPSG\",\"9122\"]],AUTHORITY[\"EPSG\",\"4326\"]]"; | |
int | |
main() | |
{ | |
GDALAllRegister(); | |
GDALDatasetH hSrcDS; | |
GDALRasterBandH hBand; | |
int nBlockXSize, nBlockYSize; | |
float *pafBlock; | |
// Src Dataset | |
hSrcDS = GDALOpen("/path/to/chirps/file/chirps-v2.0.2015.dekads.nc", GA_ReadOnly); | |
GDALSetProjection(hSrcDS, WGS84WKT); | |
hBand = GDALGetRasterBand(hSrcDS, 35); | |
nBlockXSize = 500; | |
nBlockYSize = 500; | |
pafBlock = (float *) CPLMalloc(sizeof(float)*nBlockXSize*nBlockYSize); | |
GDALRasterIO(hBand, GF_Read, 0, 0, nBlockXSize, nBlockYSize, pafBlock, nBlockXSize, nBlockYSize, GDT_Float32, 0, 0); | |
GDALClose(hSrcDS); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment