geojson 相关问题

GeoJSON是一种基于JSON的开放格式,用于编码地理数据。


转换PostGis Table(PostgreSQL)到Geojson

I访问了这个问题,显示了如何从PostgreSQL转换为Geojson格式? 此PostGIS SQL将整个桌子转换为Geojson结果: 选择Row_to_json(FC)为Geojson (Sele ...

回答 2 投票 0



</...</desc><code><?php $servername = "localhost"; $username = "root"; $password = "*****"; $dbname = "basi"; $features = array(); $geojson = array( 'type' => 'FeatureCollection', 'features' => $features ); $i=1.01; $conn = new mysqli($servername, $username, $password, $dbname); // Parse the query into geojson // ================================================ // ================================================ // Return polygons as GeoJSON for($i;$i<10;$i++){ $k=floor($i); $sql = "SELECT x1, y1 FROM afriti where floor(id)=$k"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $feature = array( 'type' => 'Feature', 'geometry' => array( 'type' => 'Polygon', 'coordinates' => array((float)$row["x1"], (float)$row["y1"]) )); array_push($features, $feature); } } } echo json_encode($geojson); ?> </code><question vote="0"> <p>我只是在完成Ajax后才打印某些东西,并且它不会输出任何内容,因此它没有结束,要么写不好写东西。 </p>它没有打印任何错误消息。 <pre> </pre> <p>对于初学者,您缺少括号</p><code>)</code><pre>在此行中:</pre> <p><code>'coordinates' => array((float)$row["x1"], (float)$row["y1"])); </code></p> <p> </p></question>

<!DOCTYPE html> <html> <head> <title>Page Title</title> <link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7/leaflet.css" /> <script src="http://cdn.leafletjs.com/leaflet-0.7/leaflet.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet-ajax/2.1.0/leaflet.ajax.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> </head> <body> <div id="map" style="width: 600px; height: 400px"></div> <script type="text/javascript"> <!-- Base Map --> var map = L.map('map').setView([40.6430126, 22.934004], 14); mapLink = '<a href="http://openstreetmap.org">OpenStreetMap</a>'; L.tileLayer( 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '&copy; ' + mapLink + ' Contributors', maxZoom: 18, }).addTo(map); </script> </body> </html> <script> //Ajax $.ajax({ method: "GET", url: "2j.php", dataType: "json", }).done(function (data) { var result = data; L.geoJson(result).addTo(map); }); </script> PHP文件 - >连接到数据库和对话! </...</desc><code><?php $servername = "localhost"; $username = "root"; $password = "*****"; $dbname = "basi"; $features = array(); $geojson = array( 'type' => 'FeatureCollection', 'features' => $features ); $i=1.01; $conn = new mysqli($servername, $username, $password, $dbname); // Parse the query into geojson // ================================================ // ================================================ // Return polygons as GeoJSON for($i;$i<10;$i++){ $k=floor($i); $sql = "SELECT x1, y1 FROM afriti where floor(id)=$k"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $feature = array( 'type' => 'Feature', 'geometry' => array( 'type' => 'Polygon', 'coordinates' => array((float)$row["x1"], (float)$row["y1"]) )); array_push($features, $feature); } } } echo json_encode($geojson); ?> </code><question vote="0"> <p>我只是在完成Ajax后才打印某些东西,并且它不会输出任何内容,因此它没有结束,要么写不好写东西。 </p>它没有打印任何错误消息。 <pre> </pre> <p>对于初学者,您缺少括号</p><code>)</code><pre>在此行中:</pre> <p><code>'coordinates' => array((float)$row["x1"], (float)$row["y1"])); </code></p> <p> </p></question>

回答 0 投票 0



无法使用鼠标悬停通过 D3 访问 GeoJSON 属性元素 - 返回未定义

我使用 GeoJSON 数据制作了许多调查站点的地图,一切看起来都很好。我还设置了一个鼠标悬停命令,当鼠标悬停在该站点上时,该命令会突出显示该站点。 然而,我正在努力创造...

回答 1 投票 0

geojson lat lon 多边形绘制较小的内部多边形

我需要编写一个函数,该函数采用基于纬度和经度值的 GeoJSON 并将多边形绘制到 2d 画布上。 除此之外,我需要添加一些距离并绘制内部多边形,其中 4 条边(北,

回答 1 投票 0

Mapbox geoJSON 格式

我正在尝试使用 MapBox 制作交互式地图。 基本思想是,人们将鼠标悬停在某些区域上,它们会亮起,并且事件将触发显示一些内容。 我得到了...

回答 2 投票 0

在 Geopandas 中将线串转换为 geojson 文件的多边形

我有以下 dxf 格式的 CAD 文件,它在 autocad 中显示如下: 我使用 GDAL org2org 将其转换为名为 test.geojson 的 geojson 格式文件,但全部类型为:LineString { “类型”:“

回答 1 投票 0

在 Kotlin 中反序列化 FeatureCollection 时出错

我正在尝试反序列化文件(.json 扩展名)中包含的 GeoJson FeatureCollection,其内容为: { "type": "特征集合", “特征”: [ { &

回答 1 投票 0

从点要素集合创建geojson多边形

我有这个特征集合,其中有很多形成形状的点: 我需要用这个形状创建一个多边形特征集合,我尝试使用 shapely multipoint.convex_hull 方法,但是

回答 1 投票 0

在 dash-leaflet geojson 弹出窗口中添加链接,单击时会有回调

我已经使用 geojson 模块使用 dash-leaflet 创建了一个交互式地图(希望模块是正确的词)。 我为每个标记创建了自定义 html 弹出窗口。我需要在弹出窗口中加入链接

回答 1 投票 0

如何修复此 geojson 中不需要的顶点?

我正在使用一个 GeoJSON 文件,该文件表示美国海拔 0 英尺的区域。然而,当我将其加载到 QGIS 中时,出现了一条奇怪的对角线,横跨地图。这...

回答 1 投票 0

从 ESRI Rest 服务检索 geojson 时出现问题

我正在尝试从此 ESRI REST 服务器获取 geojson 并将其插入 QGIS 地图。我只寻找 RptYear=2024 的点。 我已经完成了 QGIS 中单击“Ar...

回答 1 投票 0

使用 Django 序列化程序在 Leaflet 地图上添加 geoJSON 数据时出现无效对象

我正在使用 Leaflet 和 Postgresql / PostGIS 开发 Django 应用程序。当我尝试在发送 GeoJSON 要素集合对象的地图上添加 MultiLineString 图层时,它会引发无效

回答 3 投票 0

在 MongoDB C# 中为模型构造函数指定 MapCreator 仍然会导致错误

我正在尝试使用 MongoDB C# 驱动程序并在我的模型上使用 GeoJSON .Net 库而不是 MongoDB GeoJSON 类将对象存储到 MongoDB 集合(我不想实现

回答 1 投票 0

加载纽约地图

我的纽约 d3 地图将无法加载。有人可以帮忙吗? 这是我的代码: 身体 { 字体:12px 无衬线; } 小路 { 圣...</desc> <question vote="1"> <p>我的纽约 d3 地图将无法加载。有人可以帮忙吗?</p> <p>这是我的代码:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;meta charset=&#34;utf-8&#34;&gt; &lt;style&gt; body { font: 12px sans-serif; } path { stroke-width: 1.75px; stroke: #531b93; fill: #919191; cursor: pointer; } path:hover, path.highlighted { fill: #0096ff; } div.tooltip { position: absolute; background-color: white; border: 1px solid black; color: black; font-weight: bold; padding: 4px 8px; display: none; } &lt;/style&gt; &lt;body&gt; &lt;script src=&#34;http://d3js.org/d3.v3.min.js&#34;&gt;&lt;/script&gt; &lt;script&gt; //Map dimensions (in pixels) var width = 600, height = 600; //Map projection var projection = d3.geo.mercator() .scale(58722.369041340586) .center([-73.97768078496284,40.705833704252484]) //projection center .translate([width/2,height/2]) //translate to center the map in view //Generate paths based on projection var path = d3.geo.path() .projection(projection); //Create an SVG var svg = d3.select(&#34;body&#34;).append(&#34;svg&#34;) .attr(&#34;width&#34;, width) .attr(&#34;height&#34;, height); //Group for the map features var features = svg.append(&#34;g&#34;) .attr(&#34;class&#34;,&#34;features&#34;); //Create zoom/pan listener //Change [1,Infinity] to adjust the min/max zoom scale var zoom = d3.behavior.zoom() .scaleExtent([1, Infinity]) .on(&#34;zoom&#34;,zoomed); svg.call(zoom); //Create a tooltip, hidden at the start var tooltip = d3.select(&#34;body&#34;).append(&#34;div&#34;).attr(&#34;class&#34;,&#34;tooltip&#34;); d3.json(&#34;NYC_MapInfos.geojson&#34;,function(error,geodata) { if (error) return console.log(error); //unknown error, check the console //Create a path for each map feature in the data features.selectAll(&#34;path&#34;) .data(geodata.features) .enter() .append(&#34;path&#34;) .attr(&#34;d&#34;,path) .on(&#34;mouseover&#34;,showTooltip) .on(&#34;mousemove&#34;,moveTooltip) .on(&#34;mouseout&#34;,hideTooltip) .on(&#34;click&#34;,clicked); }); // Add optional onClick events for features here // d.properties contains the attributes (e.g. d.properties.name, d.properties.population) function clicked(d,i) { } //Update map on zoom/pan function zoomed() { features.attr(&#34;transform&#34;, &#34;translate(&#34; + zoom.translate() + &#34;)scale(&#34; + zoom.scale() + &#34;)&#34;) .selectAll(&#34;path&#34;).style(&#34;stroke-width&#34;, 1.75 / zoom.scale() + &#34;px&#34; ); } //Position of the tooltip relative to the cursor var tooltipOffset = {x: 5, y: -25}; //Create a tooltip, hidden at the start function showTooltip(d) { moveTooltip(); tooltip.style(&#34;display&#34;,&#34;block&#34;) .text(d.properties.PO_NAME); } //Move the tooltip to track the mouse function moveTooltip() { tooltip.style(&#34;top&#34;,(d3.event.pageY+tooltipOffset.y)+&#34;px&#34;) .style(&#34;left&#34;,(d3.event.pageX+tooltipOffset.x)+&#34;px&#34;); } //Create a tooltip, hidden at the start function hideTooltip() { tooltip.style(&#34;display&#34;,&#34;none&#34;); } &lt;/script&gt; </code></pre> <p>这是 geojson 文件: <a href="http://data.beta.nyc//dataset/3bf5fb73-edb5-4b05-bb29-7c95f4a727fc/resource/6df127b1-6d04-4bb7-b983-07402a2c3f90/download/f4129d9aa6dd4281bc98d0f701629b76nyczipcodetabulationareas.geojson" rel="nofollow">http://data.beta.nyc//dataset/3bf5fb73-edb5-4b05-bb29-7c95f4a727fc/resource/6df127b1-6d04-4bb7 -b983-07402a2c3f90/下载/f4129d9aa6dd4281bc98d0f701629b76nyczipcodetabulationareas.geojson</a></p> </question> <answer tick="true" vote="0"> <p>您可以尝试使用 <a href="https://github.com/gagan-bansal/geojson2svg" rel="nofollow noreferrer">geojson2svg</a> 模块使用 geojson 数据创建 SVG 地图。由于这只是简单的 JavaScript,因此您将拥有更多控制权。这是你的例子</p> <p>您的 html 页面 (index.html):</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;link rel=&#34;stylesheet&#34; href=&#34;./map.css&#34;/&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdnjs.cloudflare.com/ajax/libs/geojson2svg/1.0.3/geojson2svg.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdn.rawgit.com/geosquare/reproject-spherical-mercator/v0.1.3/dist/reproject-spherical-mercator.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;https://cdn.rawgit.com/geosquare/geojson-bbox/master/dist/geojson-bbox.min.js&#34;&gt;&lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h2&gt;Example of New York postal code map created with geojson2svg&lt;/h2&gt; &lt;div id=&#34;mapArea&#34; style=&#34;width:600px;height:600px;&#34;&gt; &lt;svg id=&#34;map&#34; xmlns=&#34;http://www.w3.org/2000/svg&#34; width=&#34;600&#34; height=&#34;600&#34; x=&#34;0&#34; y=&#34;0&#34; &gt; &lt;/svg&gt; &lt;div class=&#34;tooltip&#34; &gt;&lt;/div&gt; &lt;/div&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;./main.js&#34;&gt;&lt;/script&gt; &lt;/body&gt; </code></pre> <p>Javascript代码(main.js):</p> <pre><code>var dataURI = &#34;http://data.beta.nyc//dataset/3bf5fb73-edb5-4b05-bb29-7c95f4a727fc/resource/6df127b1-6d04-4bb7-b983-07402a2c3f90/download/f4129d9aa6dd4281bc98d0f701629b76nyczipcodetabulationareas.geojson&#34;; $.get(dataURI,drawGeoJSON); $(&#39;#map&#39;).on(&#39;mouseover&#39;,&#39;path&#39;,function(ev) { console.log(ev.target.feature.properties.postalCode); var tooltip = document.querySelector(&#39;.tooltip&#39;); tooltip.style.top = ev.pageY - 30; tooltip.style.left = ev.pageX + 5; tooltip.style.display = &#39;block&#39;; tooltip.innerHTML = ev.target.feature.properties.PO_NAME; }); $(&#39;#map&#39;).on(&#39;mouseout&#39;,&#39;path&#39;,function(ev) { var tooltip = document.querySelector(&#39;.tooltip&#39;); tooltip.style.display = &#39;none&#39;; }); function drawGeoJSON(geojson) { // covert wgs84 data to Web Mercator projection var geojsonMerc = reproject(geojson); // reproject: https://github.com/geosquare/reproject-spherical-mercator var extent = bbox(geojsonMerc); // bbox: https://github.com/geosquare/geojson-bbox var mapExtent = { left: extent[0], bottom: extent[1], right: extent[2], top: extent[3] }; var svgMap = document.getElementById(&#39;map&#39;); // geojson2svg: https://github.com/gagan-bansal/geojson2svg var convertor = geojson2svg( { viewportSize: {width:600,height:600}, mapExtent: mapExtent, attributes: { &#39;vector-effect&#39;:&#39;non-scaling-stroke&#39; }, explode: false } ); geojsonMerc.features.forEach(function(f) { var svgStr = convertor.convert(f,{attributes: {id: &#39;pc-&#39;+f.properties.OBJECTID}}); var svg = parseSVG(svgStr); svgMap.appendChild(parseSVG(svgStr)); var svgEle = svgMap.querySelector(&#39;#&#39; + &#39;pc-&#39;+f.properties.OBJECTID); svgEle.feature = f; }); } //parseSVG from http://stackoverflow.com/questions/3642035/jquerys-append-not-working-with-svg-element function parseSVG(s) { var div= document.createElementNS(&#39;http://www.w3.org/1999/xhtml&#39;, &#39;div&#39;); div.innerHTML= &#39;&lt;svg xmlns=&#34;http://www.w3.org/2000/svg&#34;&gt;&#39;+s+&#39;&lt;/svg&gt;&#39;; var frag= document.createDocumentFragment(); while (div.firstChild.firstChild) frag.appendChild(div.firstChild.firstChild); return frag; } </code></pre> <p>和CSS(map.css):</p> <pre><code>body { font: 12px sans-serif; } path { stroke-width: 1px; stroke: #531b93; fill: #919191; cursor: pointer; } path:hover, path.highlighted { fill: #0096ff; } div.tooltip { position: absolute; background-color: white; border: 1px solid black; color: black; font-weight: bold; padding: 4px 8px; display: none; } </code></pre> <p>如需提前使用,请查看<a href="https://maps-on-blackboard.github.io/tag/geojson2svg/" rel="nofollow noreferrer">此博客</a></p> </answer> </body></html>

回答 0 投票 0

使用 Pydeck 看不到地图高程

我正在使用topojson地图数据。 本质上,我希望根据 data_count 值看到每个区域高度的海拔。但我看到所有区域的高度相同。 get_elevation 代替

回答 1 投票 0

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.