[英]Is there a way to read a local netcdf file from a web application?
We are building a web service for data analysis and would like to access netcdf files from the local machine where the browser is running. 我们正在构建一个用于数据分析的Web服务,并希望从运行浏览器的本地计算机访问netcdf文件。 Javascript offers a file browser, but (for security reasons as I learned) it will automatically upload a file after selection, instead of allowing (read-only) access to it.
Javascript提供了文件浏览器,但是(出于安全方面的原因,据我了解),它会在选择后自动上传文件,而不是允许(只读)访问文件。 This presents a show-stopper, because the netcdf files can be HUGE .
由于netcdf文件可以是HUGE ,所以这显示了一个制止符 。 Note, that the netcdf format and API explicitly allow slicing and extraction of individual variables, which is one reason why the format is so popular.
请注意,netcdf格式和API明确允许切片和提取单个变量,这是该格式如此流行的原因之一。
Now, some research into this issue revealed that the server-client architecture normally doesn't allow access to the local file structure to prevent spying. 现在,对该问题的一些研究表明,服务器-客户端体系结构通常不允许访问本地文件结构以防止间谍活动。 On the other hand, in HTML5 there is a file API which supports exactly the kind of operations we need -- except that you can access portions of a file by specifying byte ranges, but there is no netcdf API available;
另一方面,在HTML5中,有一个文件API完全支持我们所需的操作-除了您可以通过指定字节范围来访问文件的各个部分外,但没有可用的netcdf API。 hence one would be left again with copying the entire file before being able to slice it on the server.
因此,在将整个文件切片到服务器上之前,将不得不再复制整个文件。
Of course, the other option are web services such as OpenDAP which are meant to do exactly what we want, ie access parts of a netcdf file over the internet. 当然,另一种选择是诸如OpenDAP之类的Web服务,它们可以完全执行我们想要的操作,即通过Internet访问netcdf文件的一部分。 However, this of course requires that every user would have to install the OpenDAP server before they could access their local files from within the web service.
但是,这当然要求每个用户必须先安装OpenDAP服务器,然后才能从Web服务中访问其本地文件。 (Or, at a minimum they would have to install a web server so that one could access the file via
http://localhost/...
). (或者,至少他们必须安装一个Web服务器,以便人们可以通过
http://localhost/...
访问该文件)。
So: does anyone know of a solution to read specific portions of a local netcdf file from a web application? 那么:有谁知道从Web应用程序读取本地netcdf文件特定部分的解决方案? Specifically, are there javascript tools available for this?
具体来说,有没有可用的javascript工具?
Currently you can use netcdfjs , that it's a javascript library that allows to read NetCDF v3 files. 当前,您可以使用netcdfjs ,它是一个允许读取NetCDF v3文件的javascript库。 Because it's a NodeJS package you can run it server side, and for regular size files you can read it online, here you have an example .
因为它是一个NodeJS软件包,所以您可以在服务器端运行它,对于常规大小的文件,您可以在线阅读它,这里有一个示例 。
There are no Javascript tools to read NetCDF, but there are Java libraries: http://www.unidata.ucar.edu/downloads/netcdf/index.jsp . 没有读取NetCDF的Javascript工具,但是有Java库: http : //www.unidata.ucar.edu/downloads/netcdf/index.jsp 。
You could deploy a Java Applet to read the NetCDF file locally. 您可以部署Java Applet在本地读取NetCDF文件。 From there you could have the Applet try to process the file, or communicate with a backend service, or even try to call on the Applet from Javascript: http://docs.oracle.com/javase/tutorial/deployment/applet/invokingAppletMethodsFromJavaScript.html .
从那里,您可以让Applet尝试处理文件,与后端服务进行通信,甚至尝试从Javascript调用Applet: http : //docs.oracle.com/javase/tutorial/deployment/applet/invokingAppletMethodsFromJavaScript .html 。
There are no specific Javascript libs for reading NetCDF, as far as I know. 据我所知,没有用于读取NetCDF的特定Javascript库。 But let me drop some thoughts:
但是,让我放弃一些想法:
Hope I helped. 希望我能帮上忙。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.