如何使用React.js或其他JavascSript库读取.tif文件?

发布于 2025-01-25 04:25:17 字数 131 浏览 2 评论 0原文

我想在我的Web程序中读取.tif文件。我更喜欢使用React.js或可以与React一起使用的东西进行。但是,任何基于JavaScript的解决方案都很好。我要阅读的文件包含地理位置结合的信息。它们具有每个像素的颜色编码,其位置由经度和纬度定义。

I want to read .tif files in my web program. I prefer to do it using react.js or something that will work with react. However, any javascript-based solution is good. The files I want to read contain geolocation-bound information. They have color coding for each pixel whose position is defined by longitude and latitude.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

天邊彩虹 2025-02-01 04:25:17

我正在使用React Native,并使用其他方法来读取Geoid .TIF,以适应可能觉得它有用的任何人。

我创建了一个Python程序,该程序创建了一个.DB文件,该文件可以读取本机可以读取。该DB文件包含一个矩阵,其中行是纬度和列的经度(示例:360列,180行表示1度x 1度的象限)。然后将平均高度值存储在每个单元格中。然后,在某些坐标中,您进入.db并找到高度。这是一种非常近似的方法,因为我发现很难使用.tifs或.tems on React。

I'm using react native and used a different approach for reading a geoid .tif for anyone that might find it useful.

I created a python program which creates a .db file that react native can read. This db file contains a matrix in which rows are latitude and columns longitude (Example: 360 columns, 180 rows means quadrants of 1 degree x 1 degree). Then mean altitude values are stored in each cell. Then in react native with some coordinates you enter the .db and find the altitude. This is a very approximated approach as i found it difficult to work with .tifs or .dems on react.

清君侧 2025-02-01 04:25:17
const Tiff = require('tiff.js');

function readTiff(file) {
  return new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.onload = (e) => {
      const tiff = new Tiff({ buffer: e.target.result });
      const canvas = tiff.toCanvas();
      resolve(canvas);
    };
    reader.readAsArrayBuffer(file);
  });
}

readTiff('file').then((canvas) => {
  // do something with the canvas
  console.log(canvas);
});
const Tiff = require('tiff.js');

function readTiff(file) {
  return new Promise((resolve, reject) => {
    const reader = new FileReader();
    reader.onload = (e) => {
      const tiff = new Tiff({ buffer: e.target.result });
      const canvas = tiff.toCanvas();
      resolve(canvas);
    };
    reader.readAsArrayBuffer(file);
  });
}

readTiff('file').then((canvas) => {
  // do something with the canvas
  console.log(canvas);
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文