Skip to content

Works with GDAL 3.10.2 #58

@aklofas

Description

@aklofas

(Not an issue)

I'm happy to report that file-geodatabase-api works with GDAL 3.10.2, aka "Gulf of Mexico" release (lol).

I'm compiling GDAL + file-geodatabase-api + python bindings + java bindings in linux. That way I can write/modify gdb's in python/java using esri's gdal driver (the default GDAL driver provides read-only access only).

Example python code:

from osgeo import ogr, osr, gdal

driver = ogr.GetDriverByName("FileGDB")
if driver is None: raise Exception("Could not load FileGDB driver")

gdb = driver.CreateDataSource(...)

srs = osr.SpatialReference()
srs.ImportFromEPSG(4326)
layer = gdb.CreateLayer("featureclass_name", srs, ogr.wkbMultiPolygon)

layer.CreateFields(...)

feature = ogr.Feature(layer.GetLayerDefn())
for field in fields:
    feature.SetField(...)
feature.SetGeometry(ogr.CreateGeometryFromWkb(...))
layer.CreateFeature(feature)

I've tested it working with the python+java bindings using the following build Docker image:

FROM ubuntu:latest

ARG ROOT_DIRECTORY="/app"
ARG GDAL_SOURCE="gdal-3.10.2.tar.gz"
ARG FILEGDB_SOURCE="FileGDB_API-RHEL8-64gcc83.tar.gz"

### Update system
RUN apt-get update && apt-get upgrade -y

### Install build tools
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y \
    software-properties-common build-essential cmake curl ninja-build \
    libproj-dev libgeotiff-dev libxml2-dev libssl-dev libhdf5-dev

### Install python libraries
WORKDIR /root
COPY requirements.txt .
RUN add-apt-repository -y ppa:deadsnakes/ppa && apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y python3.11 python3.11-dev python3.11-distutils python3-lxml ffmpeg libkrb5-dev
RUN curl -sS https://bootstrap.pypa.io/get-pip.py | python3.11
RUN python3.11 -m pip install --upgrade pip && python3.11 -m pip install -r requirements.txt && python3.11 -m pip install arcgis --no-deps
RUN rm requirements.txt

### Install Java libraries
# Note: jdk-headless fails with swig
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install openjdk-17-jdk ant swig

### Build and install gdal with esri filegdb
# Extract source code
WORKDIR /root
COPY build/$GDAL_SOURCE build/$FILEGDB_SOURCE ./
RUN mkdir gdal_build && tar -xzvf $GDAL_SOURCE -C gdal_build --strip-components=1
RUN mkdir filegdb_build && tar -xzvf $FILEGDB_SOURCE -C filegdb_build --strip-components=1
RUN mkdir -p gdal_build/build
# Copy filegdb libs
RUN cp filegdb_build/lib/libFileGDBAPI.so filegdb_build/lib/libfgdbunixrtl.so /usr/local/lib
# Build
WORKDIR /root/gdal_build/build
RUN cmake -G Ninja -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_JAVA_BINDINGS=ON -DGDAL_JAVA_JNI_INSTALL_DIR=/usr/lib/jni \
    -DBUILD_PYTHON_BINDINGS=ON -DPython_LOOKUP_VERSION=3.11 \
    -DGDAL_USE_FILEGDB=ON -DFileGDB_INCLUDE_DIR=../../filegdb_build/include -DFileGDB_LIBRARY=/usr/local/lib/libFileGDBAPI.so \
    ..
RUN ninja && ninja install && ldconfig
# Cleanup
WORKDIR /root
RUN rm -r $GDAL_SOURCE $FILEGDB_SOURCE gdal_build filegdb_build

### Clean up apt cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

WORKDIR $ROOT_DIRECTORY
COPY ...
EXPOSE ...
CMD ...

Notes: This uses python 3.11 and also includes arcgis python library

It's great to see all the hard work the ESRI teams have put in to make this all work well. Thanks again!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions