我必须通过OpenLayers绘制一些代码.线要素编码为GeoJSON格式.我的代码适用于硬编码的GeoJSON功能.但是,如果我将此功能放在单独的文件中并尝试加载它.它只是不起作用.我不知道加载外部GeoJSON文件有什么问题.我已经给了这两个代码.
代码1:
// This code is ok with hard coded GeoJSON features
map.addControl(new OpenLayers.Control.LayerSwitcher());
vectorLayer = new OpenLayers.Layer.Vector("Lines");
var myGeoJSON = { "type": "FeatureCollection",
"features":
[
{ "type": "Feature", "properties": { "LENGTH": 756.304000}, "geometry": { "type": "LineString", "coordinates": [ [ 18.105018, 59.231027 ], [ 18.104176, 59.230737 ], [ 18.103928, 59.230415 ], [ 18.103650, 59.230336 ], [ 18.103028, 59.230463 ], [ 18.102491, 59.230418 ], [ 18.101976, 59.230237 ], [ 18.100893, 59.230110 ], [ 18.100117, 59.230016 ], [ 18.097715, 59.230262 ], [ …Run Code Online (Sandbox Code Playgroud) 我想用数据填充GeoJson图层,然后动态过滤要显示的功能.
我已经使过滤器功能工作,但我不知道如何更改过滤器,然后刷新图层.
添加数据后,有什么办法可以更新过滤器吗?
我试图从我的矢量图层获取功能.矢量图层由Geoserver加载的GeoJSON文档组成.我尝试过vector.features但是徒劳无功.任何人都可以帮忙吗?
我正在使用与此类似的使用 python、folium 和 geojson 创建的地图。
然而,这个图像不是交互式 HTML 文档,我宁愿简单地将它导出为 png 或 svg。
使用语法:
m = folium.Map( # etc..)
m.save("filename.png")
Run Code Online (Sandbox Code Playgroud)
保存文件,但它仍然是 HTML,而不是 png。渲染 not-to-html 的正确输出命令是什么?
我有一个 geoJSON
geo = {'type': 'Polygon',
'coordinates': [[[23.08437310100004, 53.15448536100007],
[23.08459767900007, 53.15448536100007],
[23.08594514600003, 53.153587050000056],
(...)
[23.08437310100004, 53.15448536100007]]]}
Run Code Online (Sandbox Code Playgroud)
我想使用这些坐标作为 的输入shapely.geometry.Polygon。问题是 Polygon 只接受tuple值,这意味着我必须将此 geojson 转换为多边形。当我尝试将此类数据输入到多边形中时出现错误ValueError: A LinearRing must have at least 3 coordinate tuples
我试过这个:
[tuple(l) for l in geo['coordinates']]
Run Code Online (Sandbox Code Playgroud)
但这不太有效,因为它只返回这个
[([23.08437310100004, 53.15448536100007],
[23.08459767900007, 53.15448536100007],
(...)
[23.08437310100004, 53.15448536100007])]
Run Code Online (Sandbox Code Playgroud)
我需要的是这个(我认为它是一个元组)
([(23.08437310100004, 53.15448536100007),
(23.08459767900007, 53.15448536100007),
(...)
(23.08437310100004, 53.15448536100007)])
Run Code Online (Sandbox Code Playgroud)
有这个功能吗?
当我查看GeoJson的规格时,我看到支持圆圈:
http://geopriv.dreamhosters.com/geojson/geojson-spec.html#circleExample
当我尝试使用geojsonlint(http://geojsonlint.com/)中的代码时,它会给我一个错误.
输入:
{
"type": "Circle",
"coordinates": [4.884, 52.353],
"radius": 200
}
Run Code Online (Sandbox Code Playgroud)
得到:
"Circle" is not a valid GeoJSON type.
Run Code Online (Sandbox Code Playgroud)
我想通过使用d3来显示不同的兴趣点,并对地图产生一系列影响.它需要GeoJson作为输入,但是GeoJson不支持圆圈吗?
我在MongoDB中有一个带有2dsphere索引的集合.我想保存的对象如下所示:
{
"type" : "Polygon",
"coordinates" : [
[
[
5.052617929724351,
52.64653192570052
],
[
5.051738165167465,
52.64765805672784
],
[
5.054162882116928,
52.64831549553909
],
[
5.054592035559312,
52.64780777138566
],
[
5.055364511755601,
52.64790541110375
],
[
5.056094072607651,
52.64688343792051
],
[
5.054237983969346,
52.64661654927096
],
[
5.052617929724351,
52.64653192570052
]
]
]
}
Run Code Online (Sandbox Code Playgroud)
根据http://geojsonlint.com/,这是完全有效的GeoJSON.但MongoDB表示无法提取地理密钥,因为GeoJSON可能格式不正确.
任何人都可以帮助我并发现错误吗?
这是我得到的MongoDB错误:
insertDocument :: caused by :: 16755 Can't extract geo keys from object, malformed geometry?
Run Code Online (Sandbox Code Playgroud) 如果我使用以下代码LayerPoint从指定的Lat/Lng获取:
var latLng = new L.latLng(-37.81303878836989, 144.97421264648438);
var point = map.latLngToLayerPoint(latLng);
Run Code Online (Sandbox Code Playgroud)
输出如下:
o.Point
x: 86042
y: 77065
Run Code Online (Sandbox Code Playgroud)
然后,当我尝试使用以下URL访问图层磁贴时:
http://a.tile.osm.org/10/86042/77065.png
我得到404因为它是无效的X,Y.
现在,如果我使用以下代码:
map.on("click", function (e) {
console.log(e);
});
Run Code Online (Sandbox Code Playgroud)
我可以LayerPoint在纬度和经度旁边检索控制台.
latlng: o.LatLng
lat: -37.81303878836989
lng: 144.97421264648438
layerPoint: o.Point
x: 950
y: 303
Run Code Online (Sandbox Code Playgroud)
然后访问以下URL返回此图层磁贴:
http://a.tile.osm.org/10/950/303.png

问题是,它甚至看起来不是那个纬度经度的正确磁贴,也不是我的原始代码将lat lng转换为LayerPoint实际上首先返回一个有效的X,Y.
我很困惑为什么我得到这些结果.任何帮助将不胜感激.也许我做错了什么.
我不确定是否有另一种基于纬度和经度列表检索切片图层的方法?
我之后的原因是因为我希望能够为离线应用程序使用缓存的磁贴数据,而我所拥有的唯一数据是通过为客户端应用程序生成的GeoJSON有效负载的几何/坐标.
更新:
结束这个功能(感谢@scai).
根据这个链接.
var getSlippyTileLayerPoints = function (lat_deg, lng_deg, zoom) {
var x = (Math.floor((lng_deg + 180) / 360 * Math.pow(2, zoom)));
var …Run Code Online (Sandbox Code Playgroud) 我有兴趣从statistics.gov.scot下载一些边界文件,这是一个官方统计存储库,用于共享利用SPARQL查询的统计数据.
Statistics.gov.scot提供对多个管理和统计地理区域的GeoJSON边界的访问,例如地方当局管理边界或健康委员会.在我的特定情况下,我有兴趣下载一个与数据区有关的GeoJSON边界的数据集.数据区是为在小范围内传播生命结果数据而开发的统计地理区域.通过 statistics.gov.scot访问时,样本数据区看起来像这样:
可在此处访问地理位置和相关数据.相应的GeoJSON数据可在此处获得.
数据区有两次迭代,2004年生产,另一次最近更新.我想下载2004年制作的第一次迭代.根据有关统计实体的信息,我起草了以下查询:
PREFIX entity: <http://statistics.data.gov.uk/def/statistical-entity#>
PREFIX boundaries: <http://statistics.gov.scot/boundaries/>
SELECT ?boundary
WHERE {
entity:introduced <http://reference.data.gov.uk/id/day/2004-02-01>
}
LIMIT 1000
Run Code Online (Sandbox Code Playgroud)
返回以下错误消息:
Run Code Online (Sandbox Code Playgroud)Error There was a syntax error in your query: Encountered " "}" "} "" at line 7, column 3. Was expecting one of: <IRIref> ... <PNAME_NS> ... <PNAME_LN> ... <BLANK_NODE_LABEL> ... <VAR1> ... <VAR2> ... "true" ... …
我想通过javascript将一个geojson文件传递给动态创建的数据表,我无法识别文件中的列名..我试过这个..
我的代码是这样的,
<body>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>fC.type</th>
<th>f.type</th>
<th>f.prop</th>
<th>f.geom.type</th>
<th>geometry.coordinates.0</th>
<th>geometry.coordinates.1</th>
</tr>
</thead>
</table>
</body>
$(document).ready(function() {
$('#example').dataTable( {
"ajax":"data/json_file.json",
"processing":true,
"columns": [
{ "mData": "type" },
{ "mData": "features.type" },
{ "mData": "features.properties" },
{ "mData": "geometry.type" },
{ "mData": "geometry.coordinates.0" },
{ "mData": "geometry.coordinates.1" }
]
});
});
Run Code Online (Sandbox Code Playgroud)
和geojson文件是
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
40.078125,
57.136239319177434
],
[
91.7578125,
58.99531118795094
] …Run Code Online (Sandbox Code Playgroud) geojson ×10
javascript ×3
leaflet ×3
python ×2
d3.js ×1
datatable ×1
dictionary ×1
folium ×1
geo ×1
html ×1
jquery ×1
linked-data ×1
map ×1
maps ×1
mongodb ×1
opendata ×1
openlayers ×1
openlayers-3 ×1
pandas ×1
rdf ×1
shapely ×1
sparql ×1
vector ×1