Select to view content in your preferred language

GeoTiff Support

4354
6
05-30-2013 01:04 PM
Labels (1)
RyanNoble
Emerging Contributor
Does the sdk have any support for creating geotiffs (or any other georeferenced raster formats) in code? I'm planning on displaying the geotiff using code from the Raster and Shapefile example, so the raster format must be supported by that code.
0 Kudos
6 Replies
MatthewBrown1
Deactivated User
Hi Ryan,

I think it should be possible to create your raster using an array in .NET and use an in-memory raster datatype as an input to a geoprocessing package or service and containing the Copy Raster tool to write the raster to disk. Pretty sure GeoTiff is supported in Desktop, not sure about Runtime.

NumPyArrayToRaster in a Python script tool (published as a GP service or package) may also work in the Runtime SDK for WPF:

http://resources.arcgis.com/en/help/main/10.1/index.html#//018v0000005n000000

Can you provide more detail about your workflow? Are you creating the raster from existing data or from scratch?
0 Kudos
RyanNoble
Emerging Contributor
Thanks for the tip. I already found a way to do it. I just used TiffBitmapEncoder and added geotiff-related tags to the metadata field.
0 Kudos
RyanNoble
Emerging Contributor
For anyone with the same problem, here is some code for doing it:

double[] modelTiePoint = new double[24];

//Populate the modelTilePoint array
// modelTilePoint[0] = someValue;
//...

//Add our geotiff GCPs to the Tiff metadata
BitmapMetadata metaData = new BitmapMetadata("tiff");
metadata.SetQuery("/ifd/{uint=33922}", dModelTiePoint);

//Create BitmapFrame using raster data and metadata
BitmapFrame bFrame = BitmapFrame.Create(myBitmapSource, null, metadata, null);

//Write the GeoTiff to disk
TiffBitmapEncoder enc = new TiffBitmapEncoder();
enc.Frames.Add(bFrame);
enc.Compression = TiffCompressOption.None;
enc.Save(new FileStream(outputGeoTiffName, FileMode.Create));
0 Kudos
MatthewBrown1
Deactivated User
That looks like an excellent solution! I would think that method will be faster and less setup than initiating/running a GP task. Only downside seems to be that it isn't supported on XP according to:

http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.tiffbitmapencoder.aspx
0 Kudos
RyanNoble
Emerging Contributor
Thanks for the tip on XP. I missed that.
0 Kudos
TimB
by
Occasional Contributor

I know this is an old post, but i am trying to do this myself.  However, no matter what I do, the geotiff is not loading properly into a GIS app (ArcGIS Pro).  I know the modeltiepoint values are being written to the file, as i am able to read them back in with System.Drawing.Imaging.PropertyItem.

Do you have any sample code that shows exactly what you did with the tiePoints (as you mention in your pseudo-code)?  Also, do you need to set a projection anywhere?

I have seen and used the info here: http://geotiff.maptools.org/spec/geotiff2.6.html , but still no luck. 

//Populate the modelTilePoint array
// modelTilePoint[0] = someValue;
//...

0 Kudos