Show a gpkg file as the basemap

2407
7
03-05-2018 08:33 AM
AaronMurphy3
New Contributor III

Hi everyone.

Pretty simple question, does anyone know how I could show a gpkg file as a basemap? The docs haven't helped and a few samples mention geopackages but then use .shp files.

Thanks,

Aaron

0 Kudos
7 Replies
NagmaYasmin
Occasional Contributor III

Hi Aaron,

You could use the code below to display a gpkg file:

Map myMap = new Map();

// Get the full path
string geoPackagePath = "..\\..\\AuroraCO.gpkg";

// Open the GeoPackage
GeoPackage myGeoPackage = await GeoPackage.OpenAsync(geoPackagePath);

// Read the raster images and get the first one
Raster gpkgRaster = myGeoPackage.GeoPackageRasters.FirstOrDefault();

// Make sure an image was found in the package
if (gpkgRaster == null) { return; }

// Create a layer to show the raster
RasterLayer newLayer = new RasterLayer(gpkgRaster);

await newLayer.LoadAsync();
myMap.Basemap.BaseLayers.Add(newLayer);

MyMapView.Map = myMap;
await MyMapView.SetViewpointCenterAsync(39.5517, -104.8589);

gokg

Attached is the sample application. Hope that helps.

0 Kudos
AaronMurphy3
New Contributor III

Thanks Nagma, that works great!

However, I have come to realise that this will not completely fulfill my requirement. Is it possible to use a mosaic file system with ArcGIS .NET? For example, have the image split into many tile PNGs across multiple folders and when you zoom in/out of the map it requests the new tiles from a server using z/x/y parameters?

Thanks,

Aaron

0 Kudos
NagmaYasmin
Occasional Contributor III

I believe you may use MosaicDatasetRaster.AddRastersAync() method to add rasters to mosaic dataset. Have you tried this?

MosaicDatasetRaster.AddRastersAsync Method 

0 Kudos
AaronMurphy3
New Contributor III

Hi,

I saw it earlier but couldn't quite work out how to use it. Could you perhaps provide an example of how to use it with a service or even just locally? Currently with another map system we are able to just provide a url like so "../Diagrams/{z}/{x}/{y}.png"

0 Kudos
NagmaYasmin
Occasional Contributor III

Hi Aaron,

MosaicDatasetRaster takes sqlite datsset, it doesn't take png/tiff file though. So looks like the API won't work for you unless you use .geodatabase.

0 Kudos
AaronMurphy3
New Contributor III

I see!

We currently use TPK files for our maps and serve them locally. However, our customer has shown interest in us including DWG/DXF files in the ArcGIS viewer. Would you happen to know if this is possible at all? Perhaps with some form of conversion?

Aaron

0 Kudos
NagmaYasmin
Occasional Contributor III

Hello,

In ArcMap, you can export this type of file to shapefile and then consume that shape file in runtime application.

0 Kudos