Trying to load the tfw when opening a tif file

3964
24
Jump to solution
03-07-2017 08:06 AM
TorbenWiggerich
New Contributor III

Hello ,

I am trying to load a tif file (map000.tif) and also the correspondig tfw file (map000.tfw). 

What he actually does is, he loads the given map (map000.tif) and shows it. But I don't think that he loaded the tfw file correctly. (So loading two rasters they will be shown at the same position.)

There is no SpatialReference which I could set?

I tried to set the set SpatialReference of the Map (m_map) but it then shows nothing.

m_mapView = new MapGraphicsView( this );

QString dataPath = "<Path>\\map000.tif";
Esri::ArcGISRuntime::Raster * raster = new Esri::ArcGISRuntime::Raster( dataPath, this );
Esri::ArcGISRuntime::RasterLayer* rasterLayer = new Esri::ArcGISRuntime::RasterLayer( raster, this );

std::cout << "SpatialRefernce: " << rasterLayer->spatialReference().wkid() << std::endl;

mp_basemap = new Esri::ArcGISRuntime::Basemap( rasterLayer, this );
m_map = new Esri::ArcGISRuntime::Map( mp_basemap, this );
m_mapView->setMap( m_map );

What do I wrong?

A long time ago I had a similar question concering the SDK 10.2.3.

How to load the .tfw file when opening a .tif file? 

With kind regards

Torben

0 Kudos
24 Replies
LukeSmallwood
Esri Contributor

Hi Torben,

If you are able to send me the image I can try to load it to see if it works for me.

0 Kudos
TorbenWiggerich
New Contributor III

Hi Luke

I tried to upload the data here, but it is not shown... 

I tried to send it to you, but I don't have the rights to do that...

So here it is...

https://files.fm/u/9ya8m6xd 

0 Kudos
LukeSmallwood
Esri Contributor

Hi Torben - thank you for sending me through the data.

I think that the problem is that your data does not include information on the coordinate system: when you load it in a Map with no reference it ends up being displayed in Spatial Reference "0" (which as you say is not valid). In the Runtime SDK we do not support on-the-fly projection of raster data so when you try and load it into a map with a defined system (e.g. WGS84) it cannot be displayed.

For tiff files such as this one, there are a number of ways in which coordinate and projection information can be supplied. The .tfw file provides the coordinates you use in your envelope - for the coordinate system information I believe this is usually either encoded into the header of the .tif file itself or provided in a separate .aux file. Unfortunately I do not know of a straight-forward way to apply either of these approaches. If you have access to ArcMap you can use a tool such as "Define Projection" to specify the system for your file - I tried that and was able to successfully load your raster draped over another basemap in the correct location.

I hope that is helpful - I will do a little bit more research into the problem and let you know if I find a work-around.

Thanks,

Luke

0 Kudos
TorbenWiggerich
New Contributor III

Hi Luke,

it is good to hear that you can't load the image too. 

With the SDK 10.2.3 I was able to load and display the image correctly. Does this change to the current release?

The way to use ArcMap is no option for us.

With kind regards

Torben

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Torben,

This tiff file doesn't have a projection defined. I can see this by opening it in ArcCatalog (see attached image). If there is no projection defined, it will likely just display at 0,0 (aka null island), and all other data that doesn't have anything defined will display there as well. You will want to make sure the data has a projection defined before consuming in ArcGIS Runtime - Defining or modifying a raster's coordinate system—Help | ArcGIS for Desktop 

TorbenWiggerich
New Contributor III

Hi Lucas,

my current problem is that with the Runtime 10.2.3 I was able to load these images and display them at the correct position. Is this not possible with the Version 100?

Can I define it somewho in the code. Maybe that he should ever use one SpatialReference if there is no one defined?

Our customers will not have access to such a big tool (AcrGIS for Desktop). 

But they should be able to load their images correctly.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

I'm not sure how this worked before. It seems like the behavior that we are seeing now is expected. Can you post an example project from 10.2.3, along with sample data so we can take a look?

0 Kudos
TorbenWiggerich
New Contributor III

Hi Lucas,

sorry for my late reply...

Here is the example project:

https://files.fm/u/p57zgqfb#_ 

There are two images loaded and displayed correctly.

0 Kudos
TorbenWiggerich
New Contributor III

Hi Lucas, 

did you have a try on this?

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Sorry Tobern, I completely missed this. I'll be pretty tied up the next 2 weeks with the User Conference (and prep for it). I will try and take a look after.

- Luke

0 Kudos