英文:
Compressing big GeoJSON/Shapefle datasets for viewing on web browser
问题
我有一个3GB大小的shapefile,正如您所想象的,我的浏览器不喜欢它。我该如何压缩我拥有的数据,这些数据可以是经度/纬度坐标或X、Y网格上的点?
我在Computerphile上看到一个关于使用离散余弦变换来减少高维数据的视频,但作为程序员而不是数学家,我不知道这是否可能。我尝试每10步采集一个点,像这样:map[0:100000:10],但这产生了不良且非常丢失的效果。
我理想情况下希望我的数据可以像Google Earth一样工作,即分辨率会根据您的视口高度调整。因此,当您放大地图时,视口中呈现出更高频率的数据,从而限制了点的数量,但我不知道他们是如何做到这一点的,Google没有提供有价值的信息。
最后一点是,由于这些只是矢量数据,我是否可以使用任何类型的矢量压缩?我数学不太好,所以您可以想象当我研究这个问题时,我很快就会感到困惑。我了解SciPy中有一些DCT内置功能,我知道它还有一堆其他我不理解的功能,也许我可以使用这个?
英文:
So I have a shapefile that is 3GB in size and as you can imagine my browser doesn't like it. How can I compress the data I have which is either in lon/lat coordinates or points on an X,Y grid?
I saw a video on Computerphile about Discreet Cosine Transforms for reducing high dimesionality data but being a programmer and not a mathematician I don't know if this is even possible. I have tried to take a point every 10 steps in the file like so: map[0:100000:10] but this had an udesireable and very lossy effect.
I would ideally like to have my data so it would work like Google Earth in which the resolution adjusts to your viewport altitude. So when you zoom in to the map higher freqency data is presented in the viewport, limiting the amount of points but I don't know how they do this and Google return nothing of value.
Last point is that since these are just vectors is there any type of vector compression I could use? I'm not to great at math so as you can imagine when I look into this I just get confused fairly quickly. I uderstand SciPy has some DCT built in and I know it has a whole bunch of other features which I don't understand, perhaps I could use this?
答案1
得分: 1
我可以回答关于“详细级别”的部分:您可以尝试使用leaflet(一个JavaScript地图库)。然后,您可以定义一个“粗略”图层,该图层在低缩放级别下显示,并且只有在更高的缩放级别下才显示“高级别详细”图层。您可能需要捕获地图的zoomend
事件,并从那里加载/卸载您的图层。
英文:
I can answer the "level of detail" part: you can experiment with leaflet (a javascript mapping library). You could then define a "coarse" layer wich is displayed for low zoom levels and "high detail" layers that are only displayed at higher zoom levels. You probably need to capture the map zoomend
event and load/unload your layers from there.
答案2
得分: 1
这个问题的一个解决方案是使用像Web地图服务器(WMS),例如GeoServer或MapServer,将您的ShapeFile(虽然最好使用像PostGIS这样的空间数据库)存储在服务器上,并将渲染的图像(通常分解为可缓存的瓦片)发送到浏览器。
英文:
One solution to this problem is to use a Web Map Server (WMS) like GeoServer or MapServer that stores your ShapeFile (though a spatial database like PostGIS would be better) on the server and sends a rendered image (often broken down into cacheable tiles) to the browser.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论