如何解决如何使用传单和 geoJson 文件数据制作热图
我在 Qgis 中有一个热图,并使用 qgis2web 插件生成了预览页面。但是,它在页面上没有显示任何内容。我做了一些研究,做了一些测试,但我无法使用 geoJson 文件中的数据生成传单热图。有人能帮我吗? 遵循生成的代码。 谢谢。
使用数据遵循文件模型:
var json_dados_centroids = {
"type": "FeatureCollection","name": "dados","crs": { "type": "name","properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },"features": [
{ "type": "Feature","properties": { "VINC": "6" },"geometry": { "type": "MultiPoint","coordinates": [ [ -46.489342251452101,-23.66511439561954 ] ] } },{ "type": "Feature","properties": { "VINC": "1" },"coordinates": [ [ -46.489439968502133,-23.665105357310239 ] ] } },"properties": { "VINC": "0" },"coordinates": [ [ -46.489537955929293,-23.665096808547311 ] ] } },"coordinates": [ [ -46.559119794597237,-23.653810429167063 ] ] } },"coordinates": [ [ -46.489140609582904,-23.665134091460494 ] ] } }
]
}
var centroids_hm = geoJson2heat(json_dados_centroids,'VINC');
var layer_centroids = new L.heatLayer(centroids_hm,{
attribution: '',interactive: true,radius: 30,max: 11917,minOpacity: 1,gradient: {0: '#fcfdbf',0.019608: '#fcf4b6',0.039216: '#fdebac',0.0588942: '#fde2a3',0.078431: '#fed89a',0.098039: '#fecf92',0.117647: '#fec68a',0.137255: '#febd82',0.156863: '#feb47b',0.176471: '#feaa74',0.196078: '#fea16e',0.215686: '#fd9869',0.235294: '#fc8e64',0.254902: '#fb8560',0.27451: '#f97b5d',0.294118: '#f7725c',0.313725: '#f4695c',0.333333: '#f1605d',0.352941: '#ec5860',0.372549: '#e75263',0.392157: '#e04c67',0.411765: '#d9466b',0.431373: '#d2426f',0.45098: '#ca3e72',0.470588: '#c23b75',0.490196: '#ba3878',0.509804: '#b2357b',0.529412: '#aa337d',0.54902: '#a1307e',0.568627: '#992d80',0.588235: '#912b81',0.607843: '#892881',0.627451: '#812581',0.647059: '#792282',0.666667: '#721f81',0.686275: '#6a1c81',0.705882: '#621980',0.72549: '#5a167e',0.745098: '#52137c',0.764706: '#4a1079',0.784314: '#420f75',0.803922: '#390f6e',0.823529: '#311165',0.843137: '#29115a',0.862745: '#21114e',0.882353: '#1a1042',0.901961: '#140e36',0.921569: '#0e0b2b',0.941176: '#090720',0.960784: '#050416',0.980392: '#02020b',1: '#000004'}
}
);
layer_centroids.setData(centroids_hm);
function geoJson2heat(geojson,weight) {
return geojson.features.map(function(feature) {
return [
feature.geometry.coordinates[1],feature.geometry.coordinates[0],feature.properties[weight]
];
});
}
map.addLayer(layer_centroids);
解决方法
首先,您的 GeoJSON 包含多点形式的几何。但是,在 'geoJson2heat' 中,您解析点。
我建议将几何图形转换为点(在 'json_dados_centroids' 变量中)。
还需要删除 async fn main() {
let mgr = PluginManager::get();
mgr.spawn_plugins().await;
}
。
类似的东西
layer_centroids.setData(centroids_hm)
附言"VINC": "6" - 奇怪的强度值。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。