Select to view content in your preferred language

Create basemap using different raster data formats

3149
16
Jump to solution
03-10-2021 06:45 AM
VanyaIvanov
Regular Contributor

Can i use .tif, .jpg or .bmp surface images for creating a basemap? I use .tpk files from ArcGIS Pro as world surface image but i want to try other formats(.tif is preferable). What i use now that works but only with .tpk files:

TileCache tileCache = new TileCache("C:\\Users\\user\\Downloads\\WorldImagery1.tpk");
ArcGISTiledLayer[] tiledLayers = new ArcGISTiledLayer[1];
tiledLayers[0] = new ArcGISTiledLayer(tileCache);
Basemap basemap = new Basemap(Arrays.asList(tiledLayers), null);
arcscene = new ArcGISScene(basemap);
sceneView.setArcGISScene(arcscene);

 

 
0 Kudos
1 Solution

Accepted Solutions
VanyaIvanov
Regular Contributor

The problem was in CRS of my .tif images. Using Define Projection tool in ArcGIS Pro i changed CRS to the right CRS(EPSG 3857 in my case) and images started to display.

View solution in original post

0 Kudos
16 Replies
MarkBaird
Esri Regular Contributor

Tile packages (.tpk) are highly optimised file formats for showing basemap data.  They are split up into many small tiles of data and for each level of detail there is a set of tiles which are designed to work at a given scale range.  If you've got a huge amount of data then these are the best way to go.  Remember using ArcGIS Pro you can create your own.

We do however have support for adding most raster formats of data onto a map too.  The data does need to be geo-referenced raster data which means the file has information about the geographic location of the corners of the raster data.  This tells us where to display it.  If your data is not geo-referenced then I can help you with this if you have access to ArcMap or ArcGIS Pro.

So assuming you have geo-referenced raster data data you can add your own raster layers.  Will support a load of formats such as ASRP, CRF, DTED, GeoTIFF/TIFF, HFA, HRE, IMG, JPEG, JPEG2000, NITF, PNG, RPF, SRTM (HGT), USGS DEM.  

There is a simple sample which shows you how to add a raster layer from a single file: 

https://github.com/Esri/arcgis-runtime-samples-java/tree/master/raster/raster-layer-file

Does this help?

VanyaIvanov
Regular Contributor

Thank you. I tried like in the link but it doesn't work. After program starts the Earth surface on the screen is empty without any data. Maybe i have some problem in my code. I have opened this .tif file with ArcGIS Pro without any problems. (It is georeferenced country surface image. It weighs 100gb) 

private void addCountrySurface()
{
Raster raster = new Raster("E:\\Map\\countrySurface.tif");
RasterLayer rasterLayer = new RasterLayer(raster);
//rasterLayer.loadAsync();//tried with loadAsync() it doesn't work too

rasterLayer.addDoneLoadingListener(() -> {
if (rasterLayer.getLoadStatus() == LoadStatus.LOADED) {
JOptionPane.showMessageDialog(null, "Map downloaded");
} else {
JOptionPane.showMessageDialog(null, "Error");
}
});
arcscene.getOperationalLayers().add(rasterLayer);
}

 

0 Kudos
MarkBaird
Esri Regular Contributor

I've tried out your code with the sample data and it's displaying for me:

MarkBaird_0-1616003596770.png

I did however want to make sure I'd read your message correctly.  Is your file 100Gb (Gigabytes) in size?  If it really is that big, we might need to come up with a strategy for chopping it up.  

 

VanyaIvanov
Regular Contributor

Thank you. I'll try to chop.

0 Kudos
MarkBaird
Esri Regular Contributor

Chopping into smaller tiles and building pyramids on the raster data will help too.  

If you are however just using the raster data as a basemap, then do consider making a tile package.  To make things easy, make sure you use the ONLINE tiling scheme.

https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/create-map-tile-package.htm

 

VanyaIvanov
Regular Contributor

I can't add .tiff image to my scene. I tried with lighter .tif images(with weight about 100mb) but it doesn't work too. It works only with .tpk packages created from .tif images(and i have problem with creating .tpk package from big .tif images). Maybe my code sample for drawing .tif raster images is wrong?

0 Kudos
MarkBaird
Esri Regular Contributor

Are you able to display the tif file which is used in this sample:

https://github.com/Esri/arcgis-runtime-samples-java/tree/master/raster/raster-layer-file

This will display the raster in a 2D MapView application, but you should be able to display this in a scene view too.  I adapted your code sample above to zoom to the data so you don't have to find it:

 

  private void addCountrySurface()
  {
    Raster raster = new Raster("Shasta.tif");
    RasterLayer rasterLayer = new RasterLayer(raster);
    rasterLayer.addDoneLoadingListener(() -> {
      if (rasterLayer.getLoadStatus() == LoadStatus.LOADED) {
        System.out.println("raster added");
        Envelope extent = rasterLayer.getFullExtent();
        Viewpoint viewpoint = new Viewpoint(extent);
        sceneView.setViewpoint(viewpoint);
      } else {
        System.out.println("Error");
      }
    });
    scene.getOperationalLayers().add(rasterLayer);
  }

 

It is also worth noting that in 3D SceneView applications you need to be fairly zoomed in to see the raster layers, so maybe you are not seeing the raster data because you are too far zoomed out.

 

VanyaIvanov
Regular Contributor

Thank you. Doesn't work. Raster image is ok.  

 

private void addCountrySurface()
  {
    Raster raster = new Raster("Shasta.tif");
    RasterLayer rasterLayer = new RasterLayer(raster);
    rasterLayer.addDoneLoadingListener(() -> {
      if (rasterLayer.getLoadStatus() == LoadStatus.LOADED) {
        System.out.println("raster added");
        Envelope extent = rasterLayer.getFullExtent();
        Viewpoint viewpoint = new Viewpoint(extent);
        sceneView.setViewpoint(viewpoint);
        scene.getOperationalLayers().add(rasterLayer);//tried like this, but it doesnt work. In previouse variant it seems this method works before addDoneLoadinglistener() ends.
      } else {
        System.out.println("Error");
      }
    });
 
  }

 

0 Kudos
MarkBaird
Esri Regular Contributor

When you say it doesn't work, how does this is not work?  Does it load but not display, or just not load?  Are you using the sample data I suggested?

Maybe you can also provide more information like the version of SDK, OS, JDK etc so I can check things.

This is what I'm seeing with this data.

MarkBaird_0-1617209437637.png

 

At the moment I can't see what's wrong here as for me as shown in a picture earlier in this thread it loads okay and I've seen it working on macOS and Windows.