GeoTIFF for macOS
v1.7.4macOSGeoTIFF 1.7.4 for native Node.js addons and Electron on macOS, precompiled for arm64 and x64, macOS 11 or later as @crossbind/port-geotiff-darwin.
npm install @crossbind/port-geotiff-darwin@betaInstall
The addons and their loader land in dist; the Node.js playbook has the whole flow.
Usage
The examples the WebAssembly page runs, as macOS compiles them: the same headers and the same calls. They are checked on the WebAssembly build.
Find where a GeoTIFF is
The question most GeoTIFF code answers: GTIFNew reads the GeoKeys, GTIFGetDefn turns them into a coordinate system, GTIFImageToPCS places pixels on the map and GTIFProj4ToLatLong turns map coordinates into degrees.
libgeotiff 1.7.4, 10262 B: EPSG:32633 WGS 84 / UTM zone 33N, 100 x 100 pixels upper left 500000, 4650000 = 15.000000 E, 42.002015 N lower right 503000, 4647000 = 15.036210 E, 41.974990 N
Write a compressed GeoTIFF
Georeferencing is two TIFF tags and a few GeoKeys: TIFFTAG_GEOTIEPOINTS and TIFFTAG_GEOPIXELSCALE place the pixels, GTIFKeySet and GTIFWriteKeys name the coordinate system. GTIFPrint then prints the result the way listgeo does.
256 x 128 pixels: 32768 B, 23246 B as a Deflate GeoTIFF
Geotiff_Information:
Version: 1
Key_Revision: 1.0
Tagged_Information:
ModelTiepointTag (2,3):
0 0 0
-10 60 0
ModelPixelScaleTag (1,3):
0.15625 0.1953125 0
End_Of_Tags.
Keyed_Information:
GTModelTypeGeoKey (Short,1): ModelTypeGeographic
GTRasterTypeGeoKey (Short,1): RasterPixelIsArea
GTCitationGeoKey (Ascii,25): "Europe, synthetic relief"
GeographicTypeGeoKey (Short,1): GCS_WGS_84
GeogAngularUnitsGeoKey (Short,1): Angular_Degree
End_Of_Keys.
End_Of_Geotiff.Read the GeoKeys, the tiepoint and the pixel scale
GTIFDirectoryInfo counts the keys, GTIFKeyInfo and GTIFKeyGet read each one with its type, and GTIFValueNameEx names its value. The tiepoint and the pixel scale are TIFF tags, read with TIFFGetField.
GeoTIFF 1, key revision 1.0, 5 keys GTModelTypeGeoKey (Short): 2 = ModelTypeGeographic GTRasterTypeGeoKey (Short): 1 = RasterPixelIsArea GTCitationGeoKey (Ascii): "Europe" GeographicTypeGeoKey (Short): 4326 = GCS_WGS_84 GeogAngularUnitsGeoKey (Short): 9102 = Angular_Degree tiepoint: pixel 0, 0 is at -10, 60; pixel scale: 0.625 x 0.78125
Expand an EPSG code into a full definition
GTIFGetDefn normalises the GeoKeys through PROJ's EPSG database: from ProjectedCSTypeGeoKey alone it recovers the projection method and parameters, the datum, the ellipsoid and the unit. GTIFGetProj4Defn writes it as a PROJ string, with the scale factor rounded to six decimals.
ModelTypeProjected EPSG:27700 OSGB36 / British National Grid projection 19916 British National Grid, CT_TransverseMercator ProjNatOriginLatGeoKey 49 ProjNatOriginLongGeoKey -2 ProjScaleAtNatOriginGeoKey 0.9996012717 ProjFalseEastingGeoKey 400000 ProjFalseNorthingGeoKey -100000 geographic 4277 OSGB36, datum 6277 Ordnance Survey of Great Britain 1936 ellipsoid 7001 Airy 1830: 6377563.396 m, 6356256.909 m prime meridian 8901 Greenwich, unit 9001 metre (1 m) +proj=tmerc +lat_0=49.000000000 +lon_0=-2.000000000 +k=0.999601 +x_0=400000.000 +y_0=-100000.000 +a=6377563.396 +b=6356256.909 +units=m
Convert between pixels and longitude, latitude
GTIFProj4FromLatLong and GTIFPCSToImage find the pixel under a longitude and latitude; GTIFImageToPCS and GTIFProj4ToLatLong go back from a pixel. The class keeps the file open between questions.
Galata Tower: 665970.23, 4543502.03 m, pixel 159.702, 164.980 centre of pixel 159, 164: 665950, 4543550 m, 28.973939, 41.026269
What is different on macOS
crossbind build -p darwinlinks one.nodeaddon per architecture intodist, next to a loader,dist/<name>.native.cjs, thatrequireandimportboth load. A plaincrossbind buildskips it.await initNative()once, then call the classes: calls are synchronous, and no Worker is involved.- The library is linked into the addon statically; only libraries that ship with macOS stay dynamic.
- There is no
m.FS: the C++ reads real paths, and data such asGDAL_DATAorproj.dbis copied todist/data. - The build runs on a Mac with Xcode's command line tools and needs Docker for the SWIG bridges.
worker_threadsare not supported yet.
Other platforms
- GeoTIFF overview: the apps, every platform's setup and the packages.
- GeoTIFF for WebAssembly: browsers, Node.js and edge runtimes.
- GeoTIFF for Android: React Native apps on Android.
- GeoTIFF for iOS: React Native apps on iOS.
- GeoTIFF for Linux: native Node.js addons on Linux.
- GeoTIFF for Windows: native Node.js addons on Windows.
- GeoTIFF for WASI: command-line programs under wasmtime.
Facts on this page come from the port manifests in the repository and from what npm served on beta when the site was built. See the Libraries guide for the full consumer flow.