X

Help Articles are product support tips and information straight from the NV5 Geospatial Technical Support team developed to help you use our products to their fullest potential.



8643 Rate this article:
4.5

Programmatically Creating a GeoTiff Image


There are times when it is necessary to programmatically associate some geo-referencing information with a tiff file to create a geotiff. The example below demonstrates how this can be done using IDL.
The most difficult part of this program is to obtain the correct information to populate the necessary tags and geokeys. It is left to the user how and what information needs to be added but the values used in the following example represent a fairly typical scenario. 
 

; This is an example program that creates a geotiff file containing
; some of the tag and geokeys available to IDL users. The full list
; can be viewed via the IDL Help. The values used here come from
; an example found on the GeoTIFF Format Specification website:
;
;
http://www.remotesensing.org/geotiff/spec/geotiffhome.html
;
; Projection: Lambert Conformal Conic
; Central Meridian: 120 degrees West
; Pixel size: 25m
; Datum: NAD27
; Standard Parallels; 41d 20m N and 48d 40m N
; Latitude of origin: 45d N and occurs at coordinates (80, 100)
; False Easting: 200000m
; False Northing; 1500000m
;
; Although the 'ProjAzimuthAngleGeoKey' is not in the IDL list
; of geokeys it has been added here to demonstrate that it is possible
; to write other accepted geokeys and have a valid geotiff file. This
; geokeys' information is displayed when a 'tiff dump' is done on the
; file.

pro example_write_geotiff

;Create some sample tag and geokey information
  g_tags = { $
    ModelPixelScaleTag: [25, 25, 0d], $
    ModelTiepointTag: [80, 100, 0, 200000, 1500000, 0], $
    GTModelTypeGeoKey: 1, $ ; (ModelTypeProjected)
    GTRasterTypeGeoKey: 1, $ ; (RasterPixelIsArea)
    GeographicTypeGeoKey: 4267, $ ; (GCS_NAD27)
    ProjectedCSTypeGeoKey: 32767, $ ; (user-defined)
    ProjectionGeoKey: 32767, $ ; (user-defined)
    ProjLinearUnitsGeoKey: 9001, $ ; (Linear_Meter)
    ProjCoordTransGeoKey: 8, $ ; (CT_LambertConfConic_2SP)
    ProjStdParallel1GeoKey: 41.333, $
    ProjStdParallel2GeoKey: 48.666, $
    ProjCenterLongGeoKey: 120.0, $
    ProjNatOriginLatGeoKey: 45.0, $
    ProjFalseEastingGeoKey: 200000.0, $
    ProjFalseNorthingGeoKey: 1500000.0, $
    ProjAzimuthAngleGeoKey: 3094 $ ; not in IDL list but is written
    }

;Create an image for the tags and  geokeys and then
;write out the file
data = fix(dist(512))
WRITE_TIFF,'example_geotif.tif',data,/float, geotiff=g_tags

;Do a query on the file and print out the information found in the
;tags and geokeys
test=QUERY_TIFF( 'example_geotif.tif', geotiff=my_tag)
PRINT, my_tag
HELP, my_tag, /struct

END

Please login or register to post comments.
Featured

End-of-Life Policy Enforcement for ENVI 5.3 / IDL 8.5 and Earlier Versions

5/6/2024

April 1, 2024 Dear ENVI/IDL Customer,  We are reaching out to notify you of our supported... more »

How to Upgrade licenses to ENVI 6.x / IDL 9.x

12/5/2023

What is the new Upgrade function? Starting with ENVI 6.0 and IDL 9.0, we have implemented an... more »

What to do if the 'License Administrator - License Server' for the Next-Generation License Server does not start?

6/13/2023

Background: With the release of ENVI 5.7 & IDL 8.9 and the corresponding Next-Generation licensing... more »

Next-Generation Licensing FAQ

4/28/2023

  NV5 Geospatial has adopted a new licensing technology for all future releases of our ENVI, IDL... more »

The IDL Virtual Machine

6/6/2013

What is the IDL Virtual Machine? An IDL Virtual Machine is a runtime version of IDL that can... more »