FortranGIS Version 3.0
gdal.F90
1! Copyright 2011 Davide Cesari <dcesari69 at gmail dot com>
2!
3! This file is part of FortranGIS.
4!
5! FortranGIS is free software: you can redistribute it and/or modify
6! it under the terms of the GNU Lesser General Public License as
7! published by the Free Software Foundation, either version 3 of the
8! License, or (at your option) any later version.
9!
10! FortranGIS is distributed in the hope that it will be useful, but
11! WITHOUT ANY WARRANTY; without even the implied warranty of
12! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13! Lesser General Public License for more details.
14!
15! You should have received a copy of the GNU Lesser General Public
16! License along with FortranGIS. If not, see
17! <http://www.gnu.org/licenses/>.
18
27#include "gdalproto_doxy.f90"
28!!
29!! As a general guideline, note that when a \c char** object is
30!! encountered in the C interface, it should usually be interfaced in
31!! Fortran by means of the fortranc::c_ptr_ptr derived type.
32!!
33!! Other Fortran-style subroutines, functions and procedure interfaces
34!! are documented explicitely here.
35!!
36!! For an example of application of the \a gdal module, please refer
37!! to the following test program, which creates a very simple gdal
38!! raster dataset, exports it on a GEOTiff file and successively reads
39!! it:
40!! \include gdal_test.F90
41!!
42!! \ingroup libfortrangis
43MODULE gdal
44use,INTRINSIC :: iso_c_binding
45IMPLICIT NONE
46
47! Hand made symbolic constant definitions
48! GDALDataType
49INTEGER(kind=c_int),PARAMETER :: GDT_Unknown = 0
50INTEGER(kind=c_int),PARAMETER :: GDT_Byte = 1
51INTEGER(kind=c_int),PARAMETER :: GDT_UInt16 = 2
52INTEGER(kind=c_int),PARAMETER :: GDT_Int16 = 3
53INTEGER(kind=c_int),PARAMETER :: GDT_UInt32 = 4
54INTEGER(kind=c_int),PARAMETER :: GDT_Int32 = 5
55INTEGER(kind=c_int),PARAMETER :: GDT_Float32 = 6
56INTEGER(kind=c_int),PARAMETER :: GDT_Float64 = 7
57INTEGER(kind=c_int),PARAMETER :: GDT_CInt16 = 8
58INTEGER(kind=c_int),PARAMETER :: GDT_CInt32 = 9
59INTEGER(kind=c_int),PARAMETER :: GDT_CFloat32 = 10
60INTEGER(kind=c_int),PARAMETER :: GDT_CFloat64 = 11
61INTEGER(kind=c_int),PARAMETER :: GDT_TypeCount = 12
62
63! GDALAccess
64INTEGER(kind=c_int),PARAMETER :: GA_ReadOnly = 0
65INTEGER(kind=c_int),PARAMETER :: GA_Update = 1
66
67! GDALRWFlag
68INTEGER(kind=c_int),PARAMETER :: GF_Read = 0
69INTEGER(kind=c_int),PARAMETER :: GF_Write = 1
70
71INTEGER(kind=c_int),PARAMETER :: & ! GDALColorInterp
72 GCI_Undefined = 0, gci_grayindex = 1, gci_paletteindex = 2, &
73 gci_redband = 3, gci_greenband = 4, gci_blueband = 5, &
74 gci_alphaband = 6, gci_hueband = 7, gci_saturationband = 8, &
75 gci_lightnessband = 9, gci_cyanband = 10, gci_magentaband = 11, &
76 gci_yellowband = 12, gci_blackband = 13, gci_ycbcr_yband = 14, &
77 gci_ycbcr_cbband = 15,gci_ycbcr_crband = 16, gci_max = 16
78
79INTEGER(kind=c_int),PARAMETER :: & ! GDALPaletteInterp
80 GPI_Gray = 0, gpi_rgb = 1, gpi_cmyk = 2, gpi_hls = 3
81
82INTEGER(kind=c_int),PARAMETER :: & ! GDALRATFieldType
83 GFT_Integer = 0, gft_real = 1, gft_string = 2
84
85INTEGER(kind=c_int),PARAMETER :: & ! GDALRATFieldUsage
86 GFU_Generic = 0, gfu_pixelcount = 1, gfu_name = 2, gfu_min = 3, &
87 gfu_max = 4, gfu_minmax = 5, gfu_red = 6, gfu_green = 7, &
88 gfu_blue = 8, gfu_alpha = 9, gfu_redmin = 10, gfu_greenmin = 11, &
89 gfu_bluemin = 12, gfu_alphamin = 13, gfu_redmax = 14, &
90 gfu_greenmax = 15, gfu_bluemax = 16, gfu_alphamax = 17, gfu_maxcount = 18
91
92! Hand made type definitions strictly reflecting C definitions
93TYPE,BIND(C) :: gdal_gcp
94 TYPE(c_ptr) :: pszid, pszinfo
95 REAL(kind=c_double) :: dfgcppixel, dfgcpline, dfgcpx, dfgcpy, dfgcpz
96END TYPE gdal_gcp
97
98TYPE,BIND(C) :: gdalrpcinfo
99 REAL(kind=c_double) :: dfline_off, dfsamp_off, dflat_off, dflong_off, dfheight_off
100 REAL(kind=c_double) :: dfline_scale, dfsamp_scale, dflat_scale, dflong_scale, dfheight_scale
101 REAL(kind=c_double) :: adfline_num_coeff(20), adfline_den_coeff(20), &
102 adfsamp_num_coeff(20), adfsamp_den_coeff(20)
103 REAL(kind=c_double) :: dfmin_long, dfmin_lat, dfmax_long, dfmax_lat
104END TYPE gdalrpcinfo
105
106TYPE,BIND(C) :: gdalcolorentry
107 INTEGER(kind=c_short) :: c1, c2, c3, c4
108END TYPE gdalcolorentry
109
110! Machine made type definitions
111include 'gdalproto_type.f90'
112
113! Hand made interface definitions
114INTERFACE
115 SUBROUTINE gdalapplygeotransform(padfgeotransform, dfpixel, dfline, pdfgeox, pdfgeoy) bind(C,name='GDALApplyGeoTransform')
116 IMPORT
117!!GCC$ ATTRIBUTES STDCALL :: GDALApplyGeoTransform
118 REAL(kind=c_double) :: padfgeotransform(*)
119 REAL(kind=c_double),VALUE :: dfpixel
120 REAL(kind=c_double),VALUE :: dfline
121 REAL(kind=c_double) :: pdfgeox
122 REAL(kind=c_double) :: pdfgeoy
123 END SUBROUTINE gdalapplygeotransform
124END INTERFACE
125
126INTERFACE
127 FUNCTION gdalgcpstogeotransform(ngcpcount, pasgcps, padfgeotransform, bapproxok) &
128 bind(c,name='GDALGCPsToGeoTransform')
129 IMPORT
130!!GCC$ ATTRIBUTES STDCALL :: GDALGCPsToGeoTransform
131 INTEGER(kind=c_int),VALUE :: ngcpcount
132 TYPE(gdal_gcp),INTENT(in) :: pasgcps
133 REAL(kind=c_double) :: padfgeotransform(*)
134 INTEGER(kind=c_int),VALUE :: bapproxok
135 INTEGER(kind=c_int) :: gdalgcpstogeotransform
136 END FUNCTION gdalgcpstogeotransform
137END INTERFACE
138
139! Machine made interface definitions
140include 'gdalproto_interf.f90'
141
142! Fortran style interfaces
143
157 MODULE PROCEDURE gdalapplygeotransform_f_0d, gdalapplygeotransform_f_1d, &
158 gdalapplygeotransform_f_2d, gdalapplygeotransform_f_3d
159END INTERFACE
160
161PRIVATE gdalapplygeotransform_f_0d, gdalapplygeotransform_f_1d, &
162 gdalapplygeotransform_f_2d, gdalapplygeotransform_f_3d
163
164
185INTERFACE gdaldatasetrasterio_f
186 MODULE PROCEDURE gdaldatasetrasterio_int8, gdaldatasetrasterio_int16, &
187 gdaldatasetrasterio_int32, &
188 gdaldatasetrasterio_float, gdaldatasetrasterio_double, &
189 gdaldatasetrasterio_float_cmplx, gdaldatasetrasterio_double_cmplx
190END INTERFACE
191
192PRIVATE gdaldatasetrasterio_int8, gdaldatasetrasterio_int16, &
193 gdaldatasetrasterio_int32, &
194 gdaldatasetrasterio_float, gdaldatasetrasterio_double, &
195 gdaldatasetrasterio_float_cmplx, gdaldatasetrasterio_double_cmplx
196
215 MODULE PROCEDURE gdalrasterio_int8, gdalrasterio_int16, &
216 gdalrasterio_int32, &
217 gdalrasterio_float, gdalrasterio_double, &
218 gdalrasterio_float_cmplx, gdalrasterio_double_cmplx
219END INTERFACE
220
221PRIVATE gdalrasterio_int8, gdalrasterio_int16, &
222 gdalrasterio_int32, &
223 gdalrasterio_float, gdalrasterio_double, &
224 gdalrasterio_float_cmplx, gdalrasterio_double_cmplx
225
232INTERFACE gdalmajorobjecth_new
233 MODULE PROCEDURE gdalmajorobject_fromdataset_new, &
234 gdalmajorobject_fromrasterband_new, &
235 gdalmajorobject_fromdriver_new
236END INTERFACE gdalmajorobjecth_new
237
238PRIVATE gdalmajorobject_fromdataset_new, &
239 gdalmajorobject_fromrasterband_new, &
240 gdalmajorobject_fromdriver_new
241
242! internal interfaces
243INTERFACE gdaldatasetrasterio_loc
244 MODULE PROCEDURE gdaldatasetrasterio_int8_loc, gdaldatasetrasterio_int16_loc, &
245 gdaldatasetrasterio_int32_loc, &
246 gdaldatasetrasterio_float_loc, gdaldatasetrasterio_double_loc, &
247 gdaldatasetrasterio_float_cmplx_loc, gdaldatasetrasterio_double_cmplx_loc
248END INTERFACE
249PRIVATE gdaldatasetrasterio_loc
250PRIVATE gdaldatasetrasterio_int8_loc, gdaldatasetrasterio_int16_loc, &
251 gdaldatasetrasterio_int32_loc, &
252 gdaldatasetrasterio_float_loc, gdaldatasetrasterio_double_loc, &
253 gdaldatasetrasterio_float_cmplx_loc, gdaldatasetrasterio_double_cmplx_loc
254
255INTERFACE gdalrasterio_loc
256 MODULE PROCEDURE gdalrasterio_int8_loc, gdalrasterio_int16_loc, &
257 gdalrasterio_int32_loc, &
258 gdalrasterio_float_loc, gdalrasterio_double_loc, &
259 gdalrasterio_float_cmplx_loc, gdalrasterio_double_cmplx_loc
260END INTERFACE
261PRIVATE gdalrasterio_loc
262PRIVATE gdalrasterio_int8_loc, gdalrasterio_int16_loc, &
263 gdalrasterio_int32_loc, &
264 gdalrasterio_float_loc, gdalrasterio_double_loc, &
265 gdalrasterio_float_cmplx_loc, gdalrasterio_double_cmplx_loc
266
267CONTAINS
268
269! Machine made procedure definitions
270include 'gdalproto_proc.f90'
271
272! Fortran specific version of some functions
273FUNCTION gdalgcpstogeotransform_f(pasgcps, padfgeotransform, bapproxok)
274TYPE(gdal_gcp),INTENT(in) :: pasgcps(:)
275REAL(kind=c_double),INTENT(out) :: padfgeotransform(6)
276INTEGER(kind=c_int),VALUE :: bapproxok
277INTEGER(kind=c_int) :: gdalgcpstogeotransform_f
278
279gdalgcpstogeotransform_f = gdalgcpstogeotransform(SIZE(pasgcps), pasgcps(1), padfgeotransform, bapproxok)
280
281END FUNCTION gdalgcpstogeotransform_f
282
283
284! ========================================
285! gdalapplygeotransform
286! ========================================
287! this unfortunately does not work as ELEMENTAL, padfgeotransform
288! should be a scalar derived type
289SUBROUTINE gdalapplygeotransform_f_0d(padfgeotransform, &
290 dfpixel, dfline, pdfgeox, pdfgeoy)
291REAL(kind=c_double),INTENT(in) :: padfgeotransform(6)
292REAL(kind=c_double),INTENT(in) :: dfpixel
293REAL(kind=c_double),INTENT(in) :: dfline
294REAL(kind=c_double),INTENT(out) :: pdfgeox
295REAL(kind=c_double),INTENT(out) :: pdfgeoy
296
297pdfgeox = padfgeotransform(1) + &
298 dfpixel * padfgeotransform(2) + dfline * padfgeotransform(3)
299pdfgeoy = padfgeotransform(4) + &
300 dfpixel * padfgeotransform(5) + dfline * padfgeotransform(6)
301
302END SUBROUTINE gdalapplygeotransform_f_0d
303
304SUBROUTINE gdalapplygeotransform_f_1d(padfgeotransform, &
305 dfpixel, dfline, pdfgeox, pdfgeoy)
306REAL(kind=c_double),INTENT(in) :: padfgeotransform(6)
307REAL(kind=c_double),INTENT(in) :: dfpixel(:)
308REAL(kind=c_double),INTENT(in) :: dfline(:)
309REAL(kind=c_double),INTENT(out) :: pdfgeox(:)
310REAL(kind=c_double),INTENT(out) :: pdfgeoy(:)
311
312pdfgeox = padfgeotransform(1) + &
313 dfpixel * padfgeotransform(2) + dfline * padfgeotransform(3)
314pdfgeoy = padfgeotransform(4) + &
315 dfpixel * padfgeotransform(5) + dfline * padfgeotransform(6)
316
317END SUBROUTINE gdalapplygeotransform_f_1d
318
319SUBROUTINE gdalapplygeotransform_f_2d(padfgeotransform, &
320 dfpixel, dfline, pdfgeox, pdfgeoy)
321REAL(kind=c_double),INTENT(in) :: padfgeotransform(6)
322REAL(kind=c_double),INTENT(in) :: dfpixel(:,:)
323REAL(kind=c_double),INTENT(in) :: dfline(:,:)
324REAL(kind=c_double),INTENT(out) :: pdfgeox(:,:)
325REAL(kind=c_double),INTENT(out) :: pdfgeoy(:,:)
326
327pdfgeox = padfgeotransform(1) + &
328 dfpixel * padfgeotransform(2) + dfline * padfgeotransform(3)
329pdfgeoy = padfgeotransform(4) + &
330 dfpixel * padfgeotransform(5) + dfline * padfgeotransform(6)
331
332END SUBROUTINE gdalapplygeotransform_f_2d
333
334SUBROUTINE gdalapplygeotransform_f_3d(padfgeotransform, &
335 dfpixel, dfline, pdfgeox, pdfgeoy)
336REAL(kind=c_double),INTENT(in) :: padfgeotransform(6)
337REAL(kind=c_double),INTENT(in) :: dfpixel(:,:,:)
338REAL(kind=c_double),INTENT(in) :: dfline(:,:,:)
339REAL(kind=c_double),INTENT(out) :: pdfgeox(:,:,:)
340REAL(kind=c_double),INTENT(out) :: pdfgeoy(:,:,:)
341
342pdfgeox = padfgeotransform(1) + &
343 dfpixel * padfgeotransform(2) + dfline * padfgeotransform(3)
344pdfgeoy = padfgeotransform(4) + &
345 dfpixel * padfgeotransform(5) + dfline * padfgeotransform(6)
346
347END SUBROUTINE gdalapplygeotransform_f_3d
348
349
350! ========================================
351! gdaldatasetrasterio
352! ========================================
353FUNCTION gdaldatasetrasterio_int8(hds, erwflag, ndsxoff, ndsyoff, pbuffer) RESULT(err)
354TYPE(gdaldataseth),VALUE :: hds
355INTEGER(kind=c_int),INTENT(in) :: erwflag
356INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
357INTEGER(kind=c_int8_t),INTENT(inout) :: pbuffer(:,:,:)
358INTEGER(kind=c_int) :: err ! CPLErr
359
360INTEGER(kind=c_int) :: i
361
362err = gdaldatasetrasterio_loc(hds, erwflag, ndsxoff, ndsyoff, &
363 SIZE(pbuffer,1), SIZE(pbuffer,2), SIZE(pbuffer,3), pbuffer, &
364 (/(i,i=1,SIZE(pbuffer,3))/))
365
366END FUNCTION gdaldatasetrasterio_int8
367
368FUNCTION gdaldatasetrasterio_int8_loc(hds, erwflag, ndsxoff, ndsyoff, &
369 ndsxsize, ndsysize, nbandcount, pbuffer, panbandcount) RESULT(err)
370TYPE(gdaldataseth),VALUE :: hds
371INTEGER(kind=c_int),INTENT(in) :: erwflag
372INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
373INTEGER(kind=c_int),INTENT(in) :: ndsxsize
374INTEGER(kind=c_int),INTENT(in) :: ndsysize
375INTEGER(kind=c_int),INTENT(in) :: nbandcount
376INTEGER(kind=c_int8_t),TARGET,INTENT(inout) :: pbuffer(ndsxsize,ndsysize,nbandcount)
377INTEGER(kind=c_int),INTENT(in) :: panbandcount(*)
378INTEGER(kind=c_int) :: err ! CPLErr
379
380err = gdaldatasetrasterio(hds, erwflag, ndsxoff, ndsyoff, &
381 ndsxsize, ndsysize, c_loc(pbuffer(1,1,1)), &
382 ndsxsize, ndsysize, gdt_byte, nbandcount, panbandcount, 0, 0, 0)
383
384END FUNCTION gdaldatasetrasterio_int8_loc
385
386
387FUNCTION gdaldatasetrasterio_int16(hds, erwflag, ndsxoff, ndsyoff, pbuffer) RESULT(err)
388TYPE(gdaldataseth),VALUE :: hds
389INTEGER(kind=c_int),INTENT(in) :: erwflag
390INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
391INTEGER(kind=c_int16_t),INTENT(inout) :: pbuffer(:,:,:)
392INTEGER(kind=c_int) :: err ! CPLErr
393
394INTEGER(kind=c_int) :: i
395
396err = gdaldatasetrasterio_loc(hds, erwflag, ndsxoff, ndsyoff, &
397 SIZE(pbuffer,1), SIZE(pbuffer,2), SIZE(pbuffer,3), pbuffer, &
398 (/(i,i=1,SIZE(pbuffer,3))/))
399
400END FUNCTION gdaldatasetrasterio_int16
401
402FUNCTION gdaldatasetrasterio_int16_loc(hds, erwflag, ndsxoff, ndsyoff, &
403 ndsxsize, ndsysize, nbandcount, pbuffer, panbandcount) RESULT(err)
404TYPE(gdaldataseth),VALUE :: hds
405INTEGER(kind=c_int),INTENT(in) :: erwflag
406INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
407INTEGER(kind=c_int),INTENT(in) :: ndsxsize
408INTEGER(kind=c_int),INTENT(in) :: ndsysize
409INTEGER(kind=c_int),INTENT(in) :: nbandcount
410INTEGER(kind=c_int16_t),TARGET,INTENT(inout) :: pbuffer(ndsxsize,ndsysize,nbandcount)
411INTEGER(kind=c_int),INTENT(in) :: panbandcount(*)
412INTEGER(kind=c_int) :: err ! CPLErr
413
414err = gdaldatasetrasterio(hds, erwflag, ndsxoff, ndsyoff, &
415 ndsxsize, ndsysize, c_loc(pbuffer(1,1,1)), &
416 ndsxsize, ndsysize, gdt_int16, nbandcount, panbandcount, 0, 0, 0)
417
418END FUNCTION gdaldatasetrasterio_int16_loc
419
420
421FUNCTION gdaldatasetrasterio_int32(hds, erwflag, ndsxoff, ndsyoff, pbuffer) RESULT(err)
422TYPE(gdaldataseth),VALUE :: hds
423INTEGER(kind=c_int),INTENT(in) :: erwflag
424INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
425INTEGER(kind=c_int32_t),INTENT(inout) :: pbuffer(:,:,:)
426INTEGER(kind=c_int) :: err ! CPLErr
427
428INTEGER(kind=c_int) :: i
429
430err = gdaldatasetrasterio_loc(hds, erwflag, ndsxoff, ndsyoff, &
431 SIZE(pbuffer,1), SIZE(pbuffer,2), SIZE(pbuffer,3), pbuffer, &
432 (/(i,i=1,SIZE(pbuffer,3))/))
433
434END FUNCTION gdaldatasetrasterio_int32
435
436FUNCTION gdaldatasetrasterio_int32_loc(hds, erwflag, ndsxoff, ndsyoff, &
437 ndsxsize, ndsysize, nbandcount, pbuffer, panbandcount) RESULT(err)
438TYPE(gdaldataseth),VALUE :: hds
439INTEGER(kind=c_int),INTENT(in) :: erwflag
440INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
441INTEGER(kind=c_int),INTENT(in) :: ndsxsize
442INTEGER(kind=c_int),INTENT(in) :: ndsysize
443INTEGER(kind=c_int),INTENT(in) :: nbandcount
444INTEGER(kind=c_int32_t),TARGET,INTENT(inout) :: pbuffer(ndsxsize,ndsysize,nbandcount)
445INTEGER(kind=c_int),INTENT(in) :: panbandcount(*)
446INTEGER(kind=c_int) :: err ! CPLErr
447
448err = gdaldatasetrasterio(hds, erwflag, ndsxoff, ndsyoff, &
449 ndsxsize, ndsysize, c_loc(pbuffer(1,1,1)), &
450 ndsxsize, ndsysize, gdt_int32, nbandcount, panbandcount, 0, 0, 0)
451
452END FUNCTION gdaldatasetrasterio_int32_loc
453
454
455FUNCTION gdaldatasetrasterio_float(hds, erwflag, ndsxoff, ndsyoff, pbuffer) RESULT(err)
456TYPE(gdaldataseth),VALUE :: hds
457INTEGER(kind=c_int),INTENT(in) :: erwflag
458INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
459REAL(kind=c_float),INTENT(inout) :: pbuffer(:,:,:)
460INTEGER(kind=c_int) :: err ! CPLErr
461
462INTEGER(kind=c_int) :: i
463
464err = gdaldatasetrasterio_loc(hds, erwflag, ndsxoff, ndsyoff, &
465 SIZE(pbuffer,1), SIZE(pbuffer,2), SIZE(pbuffer,3), pbuffer, &
466 (/(i,i=1,SIZE(pbuffer,3))/))
467
468END FUNCTION gdaldatasetrasterio_float
469
470FUNCTION gdaldatasetrasterio_float_loc(hds, erwflag, ndsxoff, ndsyoff, &
471 ndsxsize, ndsysize, nbandcount, pbuffer, panbandcount) RESULT(err)
472TYPE(gdaldataseth),VALUE :: hds
473INTEGER(kind=c_int),INTENT(in) :: erwflag
474INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
475INTEGER(kind=c_int),INTENT(in) :: ndsxsize
476INTEGER(kind=c_int),INTENT(in) :: ndsysize
477INTEGER(kind=c_int),INTENT(in) :: nbandcount
478REAL(kind=c_float),TARGET,INTENT(inout) :: pbuffer(ndsxsize,ndsysize,nbandcount)
479INTEGER(kind=c_int),INTENT(in) :: panbandcount(*)
480INTEGER(kind=c_int) :: err ! CPLErr
481
482err = gdaldatasetrasterio(hds, erwflag, ndsxoff, ndsyoff, &
483 ndsxsize, ndsysize, c_loc(pbuffer(1,1,1)), &
484 ndsxsize, ndsysize, gdt_float32, nbandcount, panbandcount, 0, 0, 0)
485
486END FUNCTION gdaldatasetrasterio_float_loc
487
488
489FUNCTION gdaldatasetrasterio_double(hds, erwflag, ndsxoff, ndsyoff, pbuffer) RESULT(err)
490TYPE(gdaldataseth),VALUE :: hds
491INTEGER(kind=c_int),INTENT(in) :: erwflag
492INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
493REAL(kind=c_double),INTENT(inout) :: pbuffer(:,:,:)
494INTEGER(kind=c_int) :: err ! CPLErr
495
496INTEGER(kind=c_int) :: i
497
498err = gdaldatasetrasterio_loc(hds, erwflag, ndsxoff, ndsyoff, &
499 SIZE(pbuffer,1), SIZE(pbuffer,2), SIZE(pbuffer,3), pbuffer, &
500 (/(i,i=1,SIZE(pbuffer,3))/))
501
502END FUNCTION gdaldatasetrasterio_double
503
504FUNCTION gdaldatasetrasterio_double_loc(hds, erwflag, ndsxoff, ndsyoff, &
505 ndsxsize, ndsysize, nbandcount, pbuffer, panbandcount) RESULT(err)
506TYPE(gdaldataseth),VALUE :: hds
507INTEGER(kind=c_int),INTENT(in) :: erwflag
508INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
509INTEGER(kind=c_int),INTENT(in) :: ndsxsize
510INTEGER(kind=c_int),INTENT(in) :: ndsysize
511INTEGER(kind=c_int),INTENT(in) :: nbandcount
512REAL(kind=c_double),TARGET,INTENT(inout) :: pbuffer(ndsxsize,ndsysize,nbandcount)
513INTEGER(kind=c_int),INTENT(in) :: panbandcount(*)
514INTEGER(kind=c_int) :: err ! CPLErr
515
516err = gdaldatasetrasterio(hds, erwflag, ndsxoff, ndsyoff, &
517 ndsxsize, ndsysize, c_loc(pbuffer(1,1,1)), &
518 ndsxsize, ndsysize, gdt_float64, nbandcount, panbandcount, 0, 0, 0)
519
520END FUNCTION gdaldatasetrasterio_double_loc
521
522
523FUNCTION gdaldatasetrasterio_float_cmplx(hds, erwflag, ndsxoff, ndsyoff, pbuffer) RESULT(err)
524TYPE(gdaldataseth),VALUE :: hds
525INTEGER(kind=c_int),INTENT(in) :: erwflag
526INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
527COMPLEX(kind=c_float_complex),INTENT(inout) :: pbuffer(:,:,:)
528INTEGER(kind=c_int) :: err ! CPLErr
529
530INTEGER(kind=c_int) :: i
531
532err = gdaldatasetrasterio_loc(hds, erwflag, ndsxoff, ndsyoff, &
533 SIZE(pbuffer,1), SIZE(pbuffer,2), SIZE(pbuffer,3), pbuffer, &
534 (/(i,i=1,SIZE(pbuffer,3))/))
535
536END FUNCTION gdaldatasetrasterio_float_cmplx
537
538FUNCTION gdaldatasetrasterio_float_cmplx_loc(hds, erwflag, ndsxoff, ndsyoff, &
539 ndsxsize, ndsysize, nbandcount, pbuffer, panbandcount) RESULT(err)
540TYPE(gdaldataseth),VALUE :: hds
541INTEGER(kind=c_int),INTENT(in) :: erwflag
542INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
543INTEGER(kind=c_int),INTENT(in) :: ndsxsize
544INTEGER(kind=c_int),INTENT(in) :: ndsysize
545INTEGER(kind=c_int),INTENT(in) :: nbandcount
546COMPLEX(kind=c_float_complex),TARGET,INTENT(inout) :: pbuffer(ndsxsize,ndsysize,nbandcount)
547INTEGER(kind=c_int),INTENT(in) :: panbandcount(*)
548INTEGER(kind=c_int) :: err ! CPLErr
549
550err = gdaldatasetrasterio(hds, erwflag, ndsxoff, ndsyoff, &
551 ndsxsize, ndsysize, c_loc(pbuffer(1,1,1)), &
552 ndsxsize, ndsysize, gdt_cfloat32, nbandcount, panbandcount, 0, 0, 0)
553
554END FUNCTION gdaldatasetrasterio_float_cmplx_loc
555
556
557FUNCTION gdaldatasetrasterio_double_cmplx(hds, erwflag, ndsxoff, ndsyoff, pbuffer) RESULT(err)
558TYPE(gdaldataseth),VALUE :: hds
559INTEGER(kind=c_int),INTENT(in) :: erwflag
560INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
561COMPLEX(kind=c_double_complex),INTENT(inout) :: pbuffer(:,:,:)
562INTEGER(kind=c_int) :: err ! CPLErr
563
564INTEGER(kind=c_int) :: i
565
566err = gdaldatasetrasterio_loc(hds, erwflag, ndsxoff, ndsyoff, &
567 SIZE(pbuffer,1), SIZE(pbuffer,2), SIZE(pbuffer,3), pbuffer, &
568 (/(i,i=1,SIZE(pbuffer,3))/))
569
570END FUNCTION gdaldatasetrasterio_double_cmplx
571
572FUNCTION gdaldatasetrasterio_double_cmplx_loc(hds, erwflag, ndsxoff, ndsyoff, &
573 ndsxsize, ndsysize, nbandcount, pbuffer, panbandcount) RESULT(err)
574TYPE(gdaldataseth),VALUE :: hds
575INTEGER(kind=c_int),INTENT(in) :: erwflag
576INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
577INTEGER(kind=c_int),INTENT(in) :: ndsxsize
578INTEGER(kind=c_int),INTENT(in) :: ndsysize
579INTEGER(kind=c_int),INTENT(in) :: nbandcount
580COMPLEX(kind=c_double_complex),TARGET,INTENT(inout) :: pbuffer(ndsxsize,ndsysize,nbandcount)
581INTEGER(kind=c_int),INTENT(in) :: panbandcount(*)
582INTEGER(kind=c_int) :: err ! CPLErr
583
584err = gdaldatasetrasterio(hds, erwflag, ndsxoff, ndsyoff, &
585 ndsxsize, ndsysize, c_loc(pbuffer(1,1,1)), &
586 ndsxsize, ndsysize, gdt_cfloat64, nbandcount, panbandcount, 0, 0, 0)
587
588END FUNCTION gdaldatasetrasterio_double_cmplx_loc
589
590
591! ========================================
592! gdaldatasetrasterio
593! ========================================
594FUNCTION gdalrasterio_int8(hband, erwflag, ndsxoff, ndsyoff, pbuffer) RESULT(err)
595TYPE(gdalrasterbandh),VALUE :: hband
596INTEGER(kind=c_int),INTENT(in) :: erwflag
597INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
598INTEGER(kind=c_int8_t),INTENT(inout) :: pbuffer(:,:)
599INTEGER(kind=c_int) :: err ! CPLErr
600
601err = gdalrasterio_loc(hband, erwflag, ndsxoff, ndsyoff, &
602 SIZE(pbuffer,1), SIZE(pbuffer,2), pbuffer)
603
604END FUNCTION gdalrasterio_int8
605
606FUNCTION gdalrasterio_int8_loc(hband, erwflag, ndsxoff, ndsyoff, ndsxsize, ndsysize, pbuffer) RESULT(err)
607TYPE(gdalrasterbandh),VALUE :: hband
608INTEGER(kind=c_int),INTENT(in) :: erwflag
609INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
610INTEGER(kind=c_int),INTENT(in) :: ndsxsize
611INTEGER(kind=c_int),INTENT(in) :: ndsysize
612INTEGER(kind=c_int8_t),TARGET,INTENT(inout) :: pbuffer(ndsxsize,ndsysize)
613INTEGER(kind=c_int) :: err ! CPLErr
614
615err = gdalrasterio(hband, erwflag, ndsxoff, ndsyoff, &
616 ndsxsize, ndsysize, c_loc(pbuffer(1,1)), &
617 ndsxsize, ndsysize, gdt_byte, 0, 0)
618
619END FUNCTION gdalrasterio_int8_loc
620
621
622FUNCTION gdalrasterio_int16(hband, erwflag, ndsxoff, ndsyoff, pbuffer) RESULT(err)
623TYPE(gdalrasterbandh),VALUE :: hband
624INTEGER(kind=c_int),INTENT(in) :: erwflag
625INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
626INTEGER(kind=c_int16_t),INTENT(inout) :: pbuffer(:,:)
627INTEGER(kind=c_int) :: err ! CPLErr
628
629err = gdalrasterio_loc(hband, erwflag, ndsxoff, ndsyoff, &
630 SIZE(pbuffer,1), SIZE(pbuffer,2), pbuffer)
631
632END FUNCTION gdalrasterio_int16
633
634FUNCTION gdalrasterio_int16_loc(hband, erwflag, ndsxoff, ndsyoff, ndsxsize, ndsysize, pbuffer) RESULT(err)
635TYPE(gdalrasterbandh),VALUE :: hband
636INTEGER(kind=c_int),INTENT(in) :: erwflag
637INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
638INTEGER(kind=c_int),INTENT(in) :: ndsxsize
639INTEGER(kind=c_int),INTENT(in) :: ndsysize
640INTEGER(kind=c_int16_t),TARGET,INTENT(inout) :: pbuffer(ndsxsize,ndsysize)
641INTEGER(kind=c_int) :: err ! CPLErr
642
643err = gdalrasterio(hband, erwflag, ndsxoff, ndsyoff, &
644 ndsxsize, ndsysize, c_loc(pbuffer(1,1)), &
645 ndsxsize, ndsysize, gdt_int16, 0, 0)
646
647END FUNCTION gdalrasterio_int16_loc
648
649
650FUNCTION gdalrasterio_int32(hband, erwflag, ndsxoff, ndsyoff, pbuffer) RESULT(err)
651TYPE(gdalrasterbandh),VALUE :: hband
652INTEGER(kind=c_int),INTENT(in) :: erwflag
653INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
654INTEGER(kind=c_int32_t),INTENT(inout) :: pbuffer(:,:)
655INTEGER(kind=c_int) :: err ! CPLErr
656
657err = gdalrasterio_loc(hband, erwflag, ndsxoff, ndsyoff, &
658 SIZE(pbuffer,1), SIZE(pbuffer,2), pbuffer)
659
660END FUNCTION gdalrasterio_int32
661
662FUNCTION gdalrasterio_int32_loc(hband, erwflag, ndsxoff, ndsyoff, ndsxsize, ndsysize, pbuffer) RESULT(err)
663TYPE(gdalrasterbandh),VALUE :: hband
664INTEGER(kind=c_int),INTENT(in) :: erwflag
665INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
666INTEGER(kind=c_int),INTENT(in) :: ndsxsize
667INTEGER(kind=c_int),INTENT(in) :: ndsysize
668INTEGER(kind=c_int32_t),TARGET,INTENT(inout) :: pbuffer(ndsxsize,ndsysize)
669INTEGER(kind=c_int) :: err ! CPLErr
670
671err = gdalrasterio(hband, erwflag, ndsxoff, ndsyoff, &
672 ndsxsize, ndsysize, c_loc(pbuffer(1,1)), &
673 ndsxsize, ndsysize, gdt_int32, 0, 0)
674
675END FUNCTION gdalrasterio_int32_loc
676
677
678FUNCTION gdalrasterio_float(hband, erwflag, ndsxoff, ndsyoff, pbuffer) RESULT(err)
679TYPE(gdalrasterbandh),VALUE :: hband
680INTEGER(kind=c_int),INTENT(in) :: erwflag
681INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
682REAL(kind=c_float),INTENT(inout) :: pbuffer(:,:)
683INTEGER(kind=c_int) :: err ! CPLErr
684
685err = gdalrasterio_loc(hband, erwflag, ndsxoff, ndsyoff, &
686 SIZE(pbuffer,1), SIZE(pbuffer,2), pbuffer)
687
688END FUNCTION gdalrasterio_float
689
690FUNCTION gdalrasterio_float_loc(hband, erwflag, ndsxoff, ndsyoff, ndsxsize, ndsysize, pbuffer) RESULT(err)
691TYPE(gdalrasterbandh),VALUE :: hband
692INTEGER(kind=c_int),INTENT(in) :: erwflag
693INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
694INTEGER(kind=c_int),INTENT(in) :: ndsxsize
695INTEGER(kind=c_int),INTENT(in) :: ndsysize
696REAL(kind=c_float),TARGET,INTENT(inout) :: pbuffer(ndsxsize,ndsysize)
697INTEGER(kind=c_int) :: err ! CPLErr
698
699err = gdalrasterio(hband, erwflag, ndsxoff, ndsyoff, &
700 ndsxsize, ndsysize, c_loc(pbuffer(1,1)), &
701 ndsxsize, ndsysize, gdt_float32, 0, 0)
702
703END FUNCTION gdalrasterio_float_loc
704
705
706FUNCTION gdalrasterio_double(hband, erwflag, ndsxoff, ndsyoff, pbuffer) RESULT(err)
707TYPE(gdalrasterbandh),VALUE :: hband
708INTEGER(kind=c_int),INTENT(in) :: erwflag
709INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
710REAL(kind=c_double),INTENT(inout) :: pbuffer(:,:)
711INTEGER(kind=c_int) :: err ! CPLErr
712
713err = gdalrasterio_loc(hband, erwflag, ndsxoff, ndsyoff, &
714 SIZE(pbuffer,1), SIZE(pbuffer,2), pbuffer)
715
716END FUNCTION gdalrasterio_double
717
718FUNCTION gdalrasterio_double_loc(hband, erwflag, ndsxoff, ndsyoff, ndsxsize, ndsysize, pbuffer) RESULT(err)
719TYPE(gdalrasterbandh),VALUE :: hband
720INTEGER(kind=c_int),INTENT(in) :: erwflag
721INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
722INTEGER(kind=c_int),INTENT(in) :: ndsxsize
723INTEGER(kind=c_int),INTENT(in) :: ndsysize
724REAL(kind=c_double),TARGET,INTENT(inout) :: pbuffer(ndsxsize,ndsysize)
725INTEGER(kind=c_int) :: err ! CPLErr
726
727err = gdalrasterio(hband, erwflag, ndsxoff, ndsyoff, &
728 ndsxsize, ndsysize, c_loc(pbuffer(1,1)), &
729 ndsxsize, ndsysize, gdt_float64, 0, 0)
730
731END FUNCTION gdalrasterio_double_loc
732
733
734FUNCTION gdalrasterio_float_cmplx(hband, erwflag, ndsxoff, ndsyoff, pbuffer) RESULT(err)
735TYPE(gdalrasterbandh),VALUE :: hband
736INTEGER(kind=c_int),INTENT(in) :: erwflag
737INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
738COMPLEX(kind=c_float_complex),INTENT(inout) :: pbuffer(:,:)
739INTEGER(kind=c_int) :: err ! CPLErr
740
741err = gdalrasterio_loc(hband, erwflag, ndsxoff, ndsyoff, &
742 SIZE(pbuffer,1), SIZE(pbuffer,2), pbuffer)
743
744END FUNCTION gdalrasterio_float_cmplx
745
746FUNCTION gdalrasterio_float_cmplx_loc(hband, erwflag, ndsxoff, ndsyoff, ndsxsize, ndsysize, pbuffer) RESULT(err)
747TYPE(gdalrasterbandh),VALUE :: hband
748INTEGER(kind=c_int),INTENT(in) :: erwflag
749INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
750INTEGER(kind=c_int),INTENT(in) :: ndsxsize
751INTEGER(kind=c_int),INTENT(in) :: ndsysize
752COMPLEX(kind=c_float_complex),TARGET,INTENT(inout) :: pbuffer(ndsxsize,ndsysize)
753INTEGER(kind=c_int) :: err ! CPLErr
754
755err = gdalrasterio(hband, erwflag, ndsxoff, ndsyoff, &
756 ndsxsize, ndsysize, c_loc(pbuffer(1,1)), &
757 ndsxsize, ndsysize, gdt_cfloat32, 0, 0)
758
759END FUNCTION gdalrasterio_float_cmplx_loc
760
761
762FUNCTION gdalrasterio_double_cmplx(hband, erwflag, ndsxoff, ndsyoff, pbuffer) RESULT(err)
763TYPE(gdalrasterbandh),VALUE :: hband
764INTEGER(kind=c_int),INTENT(in) :: erwflag
765INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
766COMPLEX(kind=c_double_complex),INTENT(inout) :: pbuffer(:,:)
767INTEGER(kind=c_int) :: err ! CPLErr
768
769err = gdalrasterio_loc(hband, erwflag, ndsxoff, ndsyoff, &
770 SIZE(pbuffer,1), SIZE(pbuffer,2), pbuffer)
771
772END FUNCTION gdalrasterio_double_cmplx
773
774FUNCTION gdalrasterio_double_cmplx_loc(hband, erwflag, ndsxoff, ndsyoff, ndsxsize, ndsysize, pbuffer) RESULT(err)
775TYPE(gdalrasterbandh),VALUE :: hband
776INTEGER(kind=c_int),INTENT(in) :: erwflag
777INTEGER(kind=c_int),INTENT(in) :: ndsxoff, ndsyoff
778INTEGER(kind=c_int),INTENT(in) :: ndsxsize
779INTEGER(kind=c_int),INTENT(in) :: ndsysize
780COMPLEX(kind=c_double_complex),TARGET,INTENT(inout) :: pbuffer(ndsxsize,ndsysize)
781INTEGER(kind=c_int) :: err ! CPLErr
782
783err = gdalrasterio(hband, erwflag, ndsxoff, ndsyoff, &
784 ndsxsize, ndsysize, c_loc(pbuffer(1,1)), &
785 ndsxsize, ndsysize, gdt_cfloat64, 0, 0)
786
787END FUNCTION gdalrasterio_double_cmplx_loc
788
800SUBROUTINE gdaldatasetbbsize_f(hds, bbxmin, bbymin, bbxmax, bbymax, &
801 nx, ny, offsetx, offsety, xmin, ymin, xmax, ymax)
802TYPE(gdaldataseth),VALUE :: hds
803REAL(kind=c_double),INTENT(in) :: bbxmin
804REAL(kind=c_double),INTENT(in) :: bbymin
805REAL(kind=c_double),INTENT(in) :: bbxmax
806REAL(kind=c_double),INTENT(in) :: bbymax
807INTEGER,intent(out) :: nx
808INTEGER,intent(out) :: ny
809INTEGER,intent(out) :: offsetx
810INTEGER,intent(out) :: offsety
811REAL(kind=c_double),INTENT(out) :: xmin
812REAL(kind=c_double),INTENT(out) :: ymin
813REAL(kind=c_double),INTENT(out) :: xmax
814REAL(kind=c_double),INTENT(out) :: ymax
815!REAL(kind=c_double),INTENT(out) :: sx !< grid step in the x direction
816!REAL(kind=c_double),INTENT(out) :: sy !< grid step in the y direction
817
818INTEGER(kind=c_int) :: ier
819REAL(kind=c_double) :: geotrans(6), invgeotrans(6), i1r, j1r, i2r, j2r, &
820 x1, y1, x2, y2
821REAL(kind=c_double),PARAMETER :: epsy = 0.1
822INTEGER(kind=c_int) :: i1, j1, i2, j2 !, offsetx, offsety, nx, ny
823
824! ensure (anti)diagonality
825ier = gdalgetgeotransform(hds, geotrans)
826IF (.NOT.(geotrans(3) == 0.0_c_double .AND. geotrans(5) == 0.0_c_double) .AND. &
827 .NOT.(geotrans(2) == 0.0_c_double .AND. geotrans(6) == 0.0_c_double)) THEN
828 nx = -1
829 ny = -1
830 RETURN
831ENDIF
832
833! compute real indices of bounding box requested
834ier = gdalinvgeotransform(geotrans, invgeotrans)
835CALL gdalapplygeotransform(invgeotrans, bbxmin, bbymin, i1r, j1r)
836CALL gdalapplygeotransform(invgeotrans, bbxmax, bbymax, i2r, j2r)
837
838! compute integer indices of bounding box requested within the domain
839i1 = max(nint(min(i1r, i2r) - epsy), 0)
840j1 = max(nint(min(j1r, j2r) - epsy), 0)
841i2 = min(nint(max(i1r, i2r) + epsy), gdalgetrasterxsize(hds))
842j2 = min(nint(max(j1r, j2r) + epsy), gdalgetrasterysize(hds))
843offsetx = i1
844offsety = j1
845nx = max(i2 - i1, 0) ! 0=bounding box outside dataset
846ny = max(j2 - j1, 0) ! 0=bounding box outside dataset
847
848! compute output grid corners and steps
849CALL gdalapplygeotransform(geotrans, i1 + 0.5_c_double, j1 + 0.5_c_double, &
850 x1, y1)
851CALL gdalapplygeotransform(geotrans, i2 - 0.5_c_double, j2 - 0.5_c_double, &
852 x2, y2)
853
854xmin = min(x1, x2)
855ymin = min(y1, y2)
856xmax = max(x1, x2)
857ymax = max(y1, y2)
858!sx = ABS(geotrans(2)) ! improve
859!sy = ABS(geotrans(6)) ! improve
860
861END SUBROUTINE gdaldatasetbbsize_f
862
863
890SUBROUTINE gdaldatasetsimpleread_f(hds, bbxmin, bbymin, bbxmax, bbymax, pbuffer, &
891 xmin, ymin, xmax, ymax)
892TYPE(gdaldataseth),VALUE :: hds
893REAL(kind=c_double),INTENT(in) :: bbxmin
894REAL(kind=c_double),INTENT(in) :: bbymin
895REAL(kind=c_double),INTENT(in) :: bbxmax
896REAL(kind=c_double),INTENT(in) :: bbymax
897REAL(kind=c_float),ALLOCATABLE,INTENT(out) :: pbuffer(:,:,:)
898REAL(kind=c_double),INTENT(out) :: xmin
899REAL(kind=c_double),INTENT(out) :: ymin
900REAL(kind=c_double),INTENT(out) :: xmax
901REAL(kind=c_double),INTENT(out) :: ymax
902!REAL(kind=c_double),INTENT(out) :: sx !< grid step in the x direction
903!REAL(kind=c_double),INTENT(out) :: sy !< grid step in the y direction
904
905INTEGER(kind=c_int) :: ier
906INTEGER(kind=c_int) :: nx, ny, offsetx, offsety
907
908
909CALL gdaldatasetbbsize_f(hds, bbxmin, bbymin, bbxmax, bbymax, &
910 nx, ny, offsetx, offsety, xmin, ymin, xmax, ymax)
911IF (nx < 0 .OR. ny < 0) RETURN ! dataset read error
912
913ALLOCATE(pbuffer(nx, ny, gdalgetrastercount(hds)))
914IF (nx == 0 .OR. ny == 0) RETURN ! bounding box outside dataset
915
916ier = gdaldatasetrasterio_f(hds, gf_read, offsetx, offsety, pbuffer)
917IF (ier /= 0) THEN
918 DEALLOCATE(pbuffer)
919 RETURN
920ENDIF
921
922! here we should swap/transpose as requested
923
924END SUBROUTINE gdaldatasetsimpleread_f
925
926
946SUBROUTINE gdalrastersimpleread_f(hband, bbxmin, bbymin, bbxmax, bbymax, pbuffer, &
947 xmin, ymin, xmax, ymax)
948TYPE(gdalrasterbandh),VALUE :: hband
949REAL(kind=c_double),INTENT(in) :: bbxmin
950REAL(kind=c_double),INTENT(in) :: bbymin
951REAL(kind=c_double),INTENT(in) :: bbxmax
952REAL(kind=c_double),INTENT(in) :: bbymax
953REAL(kind=c_float),ALLOCATABLE,INTENT(out) :: pbuffer(:,:)
954REAL(kind=c_double),INTENT(out) :: xmin
955REAL(kind=c_double),INTENT(out) :: ymin
956REAL(kind=c_double),INTENT(out) :: xmax
957REAL(kind=c_double),INTENT(out) :: ymax
958!REAL(kind=c_double),INTENT(out) :: sx !< grid step in the x direction
959!REAL(kind=c_double),INTENT(out) :: sy !< grid step in the y direction
960
961INTEGER(kind=c_int) :: ier
962INTEGER(kind=c_int) :: nx, ny, offsetx, offsety
963
964
965CALL gdaldatasetbbsize_f(gdalgetbanddataset(hband), bbxmin, bbymin, bbxmax, bbymax, &
966 nx, ny, offsetx, offsety, xmin, ymin, xmax, ymax)
967IF (nx < 0 .OR. ny < 0) RETURN ! dataset read error
968
969ALLOCATE(pbuffer(nx, ny))
970IF (nx == 0 .OR. ny == 0) RETURN ! bounding box outside dataset
971
972ier = gdalrasterio_f(hband, gf_read, offsetx, offsety, pbuffer)
973IF (ier /= 0) THEN
974 DEALLOCATE(pbuffer)
975 RETURN
976ENDIF
977
978! here we should swap/transpose as requested
979
980END SUBROUTINE gdalrastersimpleread_f
981
982
983FUNCTION gdalmajorobject_fromdataset_new(gdalobject) RESULT(majorobject)
984TYPE(gdaldataseth),VALUE :: gdalobject
985TYPE(gdalmajorobjecth) :: majorobject
986majorobject%ptr = gdalobject%ptr
987END FUNCTION gdalmajorobject_fromdataset_new
988
989FUNCTION gdalmajorobject_fromrasterband_new(gdalobject) RESULT(majorobject)
990TYPE(gdalrasterbandh),VALUE :: gdalobject
991TYPE(gdalmajorobjecth) :: majorobject
992majorobject%ptr = gdalobject%ptr
993END FUNCTION gdalmajorobject_fromrasterband_new
994
995FUNCTION gdalmajorobject_fromdriver_new(gdalobject) RESULT(majorobject)
996TYPE(gdaldriverh),VALUE :: gdalobject
997TYPE(gdalmajorobjecth) :: majorobject
998majorobject%ptr = gdalobject%ptr
999END FUNCTION gdalmajorobject_fromdriver_new
1000
1001END MODULE gdal
Interface to a Fortran version of gdalapplygeotransform working on scalars, 1-d, 2-d and 3-d arrays.
Definition: gdal.F90:314
Simplified Fortran generic interface to the gdaldatasetrasterio C function.
Definition: gdal.F90:343
Fortran interface for formally converting a dataset, rasterband or driver opaque object into a generi...
Definition: gdal.F90:390
Simplified Fortran generic interface to the gdalrasterio C function.
Definition: gdal.F90:372
Fortran 2003 interface to the gdal http://www.gdal.org/ library.
Definition: gdal.F90:201