Hi, I want to access a local .gdb folder from the java runtime API. Is it possible to do it directly, if no then what is to be done? I'm using the below code to access the GDB file(folder). I also tried putting the GDB into a zip file but the result was same:
File geodatabaseFile = new File("C:\\Users\\gaura\\Desktop\\GeoDBSamples\\Delemont_ele" +
".gdb");
Geodatabase geodatabase = new Geodatabase(geodatabaseFile.getAbsolutePath());
geodatabase.loadAsync();
System.out.println(geodatabase.getInternal().getLoadStatus().name());
geodatabase.addDoneLoadingListener(() -> {
System.out.println("Loading GDB...");
});
while (geodatabase.getLoadStatus() != LoadStatus.LOADED) {
if (geodatabase.getLoadStatus() == LoadStatus.FAILED_TO_LOAD || geodatabase.getLoadStatus() == LoadStatus.NOT_LOADED) {
break;
}
}
System.out.println("GDB Loading Status: " + geodatabase.getLoadStatus());
if (null != geodatabase.getLoadError()) {
System.out.println("GDB Load Error Cause: " + geodatabase.getLoadError().getMessage());
}
if (geodatabase.getLoadStatus() == LoadStatus.LOADED) {
var tables = geodatabase.getGeodatabaseAnnotationTables();
for (GeodatabaseFeatureTable gdbFT : tables) {
gdbFT.addDoneLoadingListener(() -> {
System.out.println("Loading GeoDB FT...");
});
while (gdbFT.getLoadStatus() != LoadStatus.LOADED) {
if (gdbFT.getLoadStatus() == LoadStatus.FAILED_TO_LOAD || gdbFT.getLoadStatus() == LoadStatus.NOT_LOADED) {
break;
}
}
System.out.println("GDB FT Load Status: " + gdbFT.getLoadStatus());
if (gdbFT.getLoadStatus() == LoadStatus.LOADED) {
System.out.println("Fields GDB FT: " + gdbFT.getFields());
System.out.println("Geometry Type GDB FT : " + gdbFT.getGeometryType());
}
}
}
Console Output:
Loading GDB...
GDB Loading Status: FAILED_TO_LOAD
GDB Load Error Cause: No data.
It depends on where the gdb came from. If it's a Runtime geodatabase for offline purposes it will certainly work.
If it's a geodatabase straight from ArcGIS Pro, then you will have issues.
If you explain a little about the workflow you are trying to achieve I'll point you in the right direction.
Hi Mark , I'm not sure about the GDB type that I am going to get in future from my client. I will get that soon. Meanwhile can you tell me how to access it if it is from ArcGIS Pro? Also what kind of GDB should I ask the client for (technical name) if I need to access it directly from the Java API?