Skip to content

syntaxdevs/expo-gdal-pdfium

Repository files navigation

expo-gdal

Expo module for processing GeoPDF files using GDAL with coordinate transformation to WGS84.

Features

  • Read GeoPDF metadata and information
  • Render GeoPDF files to PNG images
  • Transform coordinates from native CRS to WGS84 (EPSG:4326)
  • List available GDAL drivers
  • Get GDAL version information

Installation

From GitHub

npm install https://github.com/syntaxdevs/expo-gdal.git
# or
yarn add https://github.com/syntaxdevs/expo-gdal.git

From npm (if published)

npm install expo-gdal
# or
yarn add expo-gdal

Example App

This repository includes an example Expo app for testing the module locally.

Run the example app

cd example
npm install

Then run on a device or simulator:

npx expo run:ios
# or
npx expo run:android

Prerequisites

This module requires the GDAL native libraries for both platforms:

  • Android: android/libs/gdal-release.aar
  • iOS: ios/GDAL.xcframework

Make sure both native libraries are present in the correct locations.

Usage

import { 
  getVersionInfo, 
  listDrivers, 
  readGeoPDF, 
  renderGeoPDFToPng 
} from 'expo-gdal';

// Get GDAL version information
const versionInfo = await getVersionInfo();

// List available GDAL drivers
const drivers = await listDrivers();

// Read GeoPDF metadata
const pdfInfo = await readGeoPDF('/path/to/file.pdf');

// Render GeoPDF to PNG with WGS84 coordinates
const result = await renderGeoPDFToPng(
  '/path/to/input.pdf',
  '/path/to/output.png'
);

// Access transformed coordinates (WGS84)
console.log('Top-left:', result.result?.topLeft); // { x: longitude, y: latitude }
console.log('Center:', result.result?.center);   // { x: longitude, y: latitude }

API

getVersionInfo()

Returns GDAL version information.

Returns: Promise<VersionInfoResponse>

listDrivers()

Lists all available GDAL drivers.

Returns: Promise<DriversListResponse>

readGeoPDF(filePath: string)

Reads GeoPDF file metadata and information.

Parameters:

  • filePath (string): Path to the GeoPDF file

Returns: Promise<ReadGeoPDFResponse>

renderGeoPDFToPng(inputPath: string, outputPath: string)

Renders a GeoPDF file to a PNG image and returns WGS84 coordinates.

Parameters:

  • inputPath (string): Path to the input GeoPDF file
  • outputPath (string): Path where the PNG will be saved

Returns: Promise<RenderGeoPDFResponse>

The response includes:

  • width, height: Image dimensions in pixels
  • geoTransform: GeoTransform matrix
  • topLeft, topRight, bottomLeft, bottomRight: Corner coordinates in WGS84 (longitude, latitude)
  • center: Center coordinates in WGS84 (longitude, latitude)

Coordinate System

All coordinates returned by renderGeoPDFToPng are automatically transformed to WGS84 (EPSG:4326) format:

  • x: Longitude in decimal degrees (-180 to 180)
  • y: Latitude in decimal degrees (-90 to 90)

This makes the coordinates compatible with most mapping libraries and services.

License

MIT

Repository

https://github.com/syntaxdevs/expo-gdal

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors