If you’re building a geospatial application in Node.js or clientside JavaScript, you may need to eventually extract data from a raster at a specific coordinate — or a large number of them. This historically hasn’t been very straightforward in JavaScript, as the most common format for geospatial rasters is the GeoTIFF file type, which cannot be easily parsed.

Image by author

There are a few solutions available, and with recent advances in the JavaScript language and Node ecosystem, this is no longer the technological hurdle it used to be.

GDAL?

Before JavaScript had any real ability to parse GeoTIFF files — unless you rolled your own wrappers around a lower-level programming language — your best bet was to call another application via exec(), such as a python script or command-line utility. One that immediately comes to mind is gdallocationinfo , which is part of the GDAL suite and can be used to query a raster using a latitude and longitude, like so:

gdallocationinfo -valonly -wgs84 <geotiff filename> <longitude> <latitude>

If you’re just querying a point in a raster, this approach is good enough. However, there are some issues:

  • If doing this clientside, the user must have GDAL installed.
  • There is an overhead to calling this via exec() in addition to parsing the file every time.

#geospatial-data #gis #web-development #nodejs

GeoTIFF Coordinate Querying with JavaScript
3.95 GEEK