Example on rasterlayer with Jpeg 2000?

1341
5
02-27-2018 07:39 AM
MarcusHakansson
New Contributor II

I've been searching for examples on how to create a RasterLayer from *.JP2 files but haven't found any.

I had no problems adding the jp2 file in ArcMap 10.3 but when I try to add it as an rasterLayer i get SpatialReference = null;

I have had no problems with other file formats iv'e tried.

Heres my code

Raster inRaster = new Raster(myFileSource);
await inRaster.LoadAsync();

RasterLayer newRasterLayer = new RasterLayer(inRaster);

this.MyMap.OperationalLayers.Add(newRasterLayer);

0 Kudos
5 Replies
ThadTilton
Esri Contributor

Hey Marcus,

I tested with a JPEG 2000 image I found here, and had no problems displaying the raster layer in an ArcGIS Runtime (WPF) app. A *.JP2 file stores spatial reference info directly in the file using Geography Markup Language (GML). If you open it in a text editor (Notepad++, e.g.), you should see info like this:

<gml:ProjectedCRS gml:id="ogrcrs1">
  <gml:srsName>NAD_1983_HARN_StatePlane_Delaware_FIPS_0700</gml:srsName>
  <gml:baseCRS>

  ...

Can you confirm that your image has coordinate system info defined? It might be that ArcMap handles the missing spatial reference by simply assigning a default (?).

0 Kudos
MarcusHakansson
New Contributor II

Hey Thad,

I tried the JP2 you linked to and had no problems displaying the raster layer in my ArcGIS Runtime app.

So I inspected both JP2 files in Notepad++ and my JP2 file does not have the ProjectedCRS tag.

However my FeatureCollection does contain some informatorn about the spatial reference.

Here's where the info about spatial reference is stored in my JP2

<gml:origin>
<gml:Point srsName="urn:ogc:def:crs:EPSG::32755">

<gml:pos>309749.000000000000000 5818934.000000000000000</gml:pos>

</gml:Point>

</gml:origin>


<gml:offsetVector srsName="urn:ogc:def:crs:EPSG::32755">0.500000000000000 0</gml:offsetVector>

<gml:offsetVector srsName="urn:ogc:def:crs:EPSG::32755">0 -0.500000000000000</gml:offsetVector>

0 Kudos
MarcusHakansson
New Contributor II

I could also add that its one of the files in a Pleiad 

0 Kudos
ThadTilton
Esri Contributor

I ran this past someone more knowledgeable with using raster in the runtime, and they suspect it might be a bug. We'll investigate further and try to find a resolution. In the meantime, would it be possible to share one of the images that gives you the problem? If so, you can contact me directly at ttilton@esri.com. If the file zips smaller than 20 megs or so, feel free to simply attach it to an email. Otherwise, we can arrange another way to share it.

Thanks, Thad

0 Kudos
MarcusHakansson
New Contributor II

Thank you for your response.

Sadly I'm not sure its possible for me to share the images.

Even do I know that it probably will make it more difficult to solve.

Please tell me if there something else I can do to help.

0 Kudos