SpatialReference pour raster layer

266
7
06-03-2020 08:44 AM
GEORLEVE2019
New Contributor

Bonjour,

Dans notre application mobile, nous utilisons des images géoréférencées provenant d'autres applications. Ces images ont été générés avec la projection Lambert93.

Nous utilisons les instructions suivantes:

<<<

Esri.ArcGISRuntime.Rasters.Raster rasterFile = new Esri.ArcGISRuntime.Rasters.Raster(rasterFileName);
rasterLayer = new RasterLayer(rasterFile) { Name = "IMG_" + rasterFileName };

await rasterLayer.LoadAsync();

CurrentMap.OperationalLayers.Add( rasterLayer);

>>>

Nous obtenons un message d'erreur indiquant que le SpatialReference n'est pas défini.

Que faire pour forcer le SpatialReference à "Lambert93" ?

0 Kudos
7 Replies
MichaelBranscomb
Esri Frequent Contributor

Hi,

Does "CurrentMap" already contain a Basemap or other layers in the OperationalLayers collection when you add the raster data?

Thanks

Mike

0 Kudos
GEORLEVE2019
New Contributor

Hi,

Yes, the Basemap already has a map in it and OperationalLayers is filled.

Thanks,

Augustin

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Because the Map already has a Basemap that will have determined the spatial reference of the MapView. Most layers in the OperationalLayers collection will be reprojected on-the-fly if they don't match the spatial reference of the MapView. 

The .tfw file you attached should define the projection of the raster dataset and allow it to be displayed.

Do you see and LoadError (on the layer) or LayerViewState error (on the MapView)?

Thanks

Mike 

0 Kudos
GEORLEVE2019
New Contributor

Hello Mike,

Here is what i get in LayerViewState Error :

Esri.ArcGISRuntime.ArcGISRuntimeException: Internal error: The raster layer does not have a spatial reference.

I have an other raster file which displays correctly.

What is missing in the .tif and .tfw files ? And how can I dynamically add these informations ?

Thanks

Augustin

0 Kudos
GEORLEVE2019
New Contributor

Hi Mike,

Any other idea about my request ?

Thanks

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Hi,

Unfortunately your raster dataset is missing spatial reference information. You can use the ArcGIS Pro `Define Projection` tool to add the spatial reference information.

Are you building a WPF application?

Thanks

Mike 

0 Kudos
GEORLEVE2019
New Contributor

Hi,

No I'm building an Xamarin forms application with the ArcGis Runtime SDK for .Net.

Where can I find the 'Define Projection' tool and how to make it available and easy for use to my users ?

0 Kudos