标签: geojson

KML 到 geoJSON - 如何包含样式?

我们一直在使用 KML 来允许客户将图层上传到基于 Google 地图的应用程序。我们正在尝试用 geoJSON 替换 KML,除了样式之外一切都很好。

KML 文件中的样式定义不会包含在转换的 geoJSON 文件中(我们使用了许多转换器,但我们主要使用的是http://converter.mygeodata.eu/

正如您在下面的 KML 中看到的,那里有一个样式块(紫色框),但这只是从任何生成的 geoJSON 中排除。

有谁知道保留样式的转换器或将 KML 转换为 geoJSON 的方法?

谢谢

贾森

在此输入图像描述

kml geojson google-maps-api-3

1
推荐指数
1
解决办法
3291
查看次数

Mapbox GL添加json作为数据源

我目前正在从事一个涉及 Mapbox GL 的项目。我从服务器获取一个 json 文件,其中包含很多位置点。该文件具有以下结构:

{"location": {"lat": 50.62914, "lon": 5.61972}}
Run Code Online (Sandbox Code Playgroud)

现在我想将它们放置在地图盒中的图层上。问题是mapbox仅支持GeoJSON。因此,我尝试通过以下解决方法来解决此问题。

function updateMap(data) {
    console.log("Updating map with " + data.length + " users");
    // Converting my json file into a Geojson format by returning type:point, coordinates for every json entry
    data.forEach(function(d) {
        return {
            "type": "Point",
            "coordinates": [d.location.lon, d.location.lat]
        };
    });
};
Run Code Online (Sandbox Code Playgroud)

我不确定这是否可能,所以如果我错了,请纠正我。我想我必须在 forEach 循环之外返回它,否则我只会得到第一个结果。

接下来是添加此 geojson 文件作为图层的源。看起来像这样的东西:

map.on('load', function () {
    map.addSource('point', {
        "type": "geojson",
        "data": //need to add the points that I returned above here.
    });

    map.addLayer({ …
Run Code Online (Sandbox Code Playgroud)

json return geojson mapbox

1
推荐指数
1
解决办法
3979
查看次数

如何在 Spring Boot 中从 mongodb 更改 geojson (GeoJsonPolygon) 的编组?

我以前从未使用过 Spring Boot,我想使用 mongodb 创建一个小型 REST 服务。我正在数据库中存储一些空间数据,并希望通过其余接口访问它们。这有效并且非常简单,但我正在努力解决使用默认的 mappig/marshalling 获得的 Geojson 表示。

到目前为止,这是我所拥有的:

波乔:

@Document(collection = "geofences")
public class Geofence {
    @Id
    private String id;
    private String topic;
    private Date expiresOn;
    private GeoJsonPolygon geo;

    // getters and setters 
}
Run Code Online (Sandbox Code Playgroud)

mongodb 中的文档:

{ "_id" : ObjectId("5816b03b71e2e892bd7846f3"), "topic" : "ok", "expiresOn" : ISODate("2017-01-01T00:00:00Z"), "geo" : { "type" : "Polygon", "coordinates" : [ [ [ 0, 0 ], [ 3, 6 ], [ 6, 1 ], [ 0, 0 ] ] ] } } …
Run Code Online (Sandbox Code Playgroud)

java rest mongodb geojson spring-boot

1
推荐指数
1
解决办法
935
查看次数

将 shp 文件或 geojson 转换为 isobus iso-xml ISO 11783-10

有人有过使用 ISOBUS Iso-XML (ISO 11783-10) 的经验吗?

我想将一些 geojson 和/或 shapefile (.shp) 转换为这种格式,但找不到任何信息。

iso shapefile geojson

1
推荐指数
1
解决办法
3463
查看次数

如何在传单上放置带有 geojson 的数字标记

忘记一切,直到这里,我花了黎明时间尝试,看看我是否可以继续前进,我会解释。我有一张地图,我需要列举 1 到 15 个标记。标记是正确的,标记只有1、15次的问题。这是我的json:

https://github.com/eltonsantos/analise_integrada/blob/master/path.js

简单的json,没什么

我的代码是:

var rotas = L.geoJSON(paradas, {
    onEachFeature: onEachFeature,
    pointToLayer: function(feature, latlng){
        console.log("Qtd: " + paradas.features.length)
        for(var i = 1; i <= paradas.features.length; i++){
            return L.marker(latlng, {
                icon: new L.AwesomeNumberMarkers({
                    number: i,
                    markerColor: 'purple'
                })
            })
        }
    }
}).addTo(map);
Run Code Online (Sandbox Code Playgroud)

这段代码没有显示任何错误信息,它只是显示我所有的点都用 1 编号。我只是希望它们根据 json 中的数量从 1 到 15 编号

javascript json markers geojson leaflet

1
推荐指数
1
解决办法
928
查看次数

将 OpenLayers 多边形转换为具有不同投影的 GeoJSON

类似于这个问题中发现的问题

如何将 OpenLayers 多边形坐标转换为经纬度?

我已经设置了一个基本地图来捕获用户定义的多边形并将其转换为 GeoJSON,而我可以使用其原生投影 (ESPG:3857) 来做到这一点我想获取捕获的 GeoJSON 并将其转换为 EPSG:4326 - 然后我会保存它。使用上述方法在 drawend 事件上捕获特征并执行变换会删除多边形,因为新坐标不再显示在地图的投影中。我无法弄清楚如何在不删除现有多边形的情况下以我需要的格式保存 GeoJSON

我尝试通过在多边形的矢量源上使用 getFeatures 来执行此操作,然后执行从我使用的投影到我想要的投影的变换,但这仍然返回相同的坐标,我也有(如链接的文章)尝试使用 writeFeatureObject 但它仍然不正确地保存

https://jsfiddle.net/20gxo3nt/


dragBox.on('drawend', function(evt){

/*   geom = evt.feature.getGeometry().transform('EPSG:3857', 'EPSG:4326');
  console.log(geom.getCoordinates()); */

});

$( "#save" ).click(function() {
  var geom=vectorSource.getFeatures();
  console.log(geom);
  var writer=new ol.format.GeoJSON();
  var geoJsonStr = writer.writeFeatures(geom);
  console.log (geom.proj.transform('EPSG:3857', 'EPSG:4326'));
  /* console.log(geoJsonStr) */
});
Run Code Online (Sandbox Code Playgroud)

取消注释 drawend 事件上的代码将正确 console.log 坐标,以及演示多边形消失

javascript geojson openlayers-3

1
推荐指数
1
解决办法
2903
查看次数

如何从 geoJSON 文件计算多个 MultiPolygons 的面积?

我正在尝试计算 GeoJSON 文件中每个要素(即邻域)的面积。理想情况下,结果将添加为文件中的字段或单独的数据框中,但是我目前甚至无法计算该区域。我的代码如下:

import urllib
import json
from area import area

bdry_url = urllib.request.urlopen("https://data.edmonton.ca/resource/xu6q-xcmj.geojson")
with bdry_url as bdry_file:
    bdry = json.load(bdry_file)


for x in bdry['features']:
    print(area(x))
Run Code Online (Sandbox Code Playgroud)

上面代码的结果是很多 0。area 函数应该“计算任何 GeoJSON 几何图形内的面积”。所以,我不确定我是否只是没有正确地将文件传递给函数,或者函数是否不喜欢文件中的“MultiPolygons”。

当我只print(x)for循环中使用时,输出例如:

{'type': 'Feature', 'geometry': {'type': 'MultiPolygon', 'coordinates': [[[[-113.47970029870794, 53.6152271386194], [-113.47623664663439, 53.61561158319339], [-113.4744820422431, 53.6158162210957], [-113.4731808787134, 53.61590027235317], [-113.4674204545053, 53.61591375444001], [-113.46742798260262, 53.610538856185805], [-113.46743523571406, 53.60691755885339], [-113.46961818955656, 53.60690984975463], [-113.47022601929541, 53.60689581095175], [-113.47086485888067, 53.60685578200864], [-113.4715850828474, 53.606767279197136], [-113.47225008266139, 53.606645830070825], [-113.47373112695321, 53.6063652736457], [-113.47641979230873, 53.6058984811946], [-113.47672620998279, 53.60585027816153], [-113.47791436479508, 53.60576846613057], [-113.48101443948326, 53.605768565180774], [-113.48173969843924, 53.605811862524945], …
Run Code Online (Sandbox Code Playgroud)

python geojson python-3.x

1
推荐指数
1
解决办法
537
查看次数

在Python中替换JSON文件的多个键和值

对于 geojson 类型文件,命名data如下:

{
    "type": "FeatureCollection",
    "name": "entities",
    "features": [{
            "type": "Feature",
            "properties": {
                "Layer": "0",
                "SubClasses": "AcDbEntity:AcDbPolyline",
                "EntityHandle": "1A0"
            },
            "geometry": {
                "type": "LineString",
                "coordinates": [
                    [3220.136443006845184, 3001.530372177397112],
                    [3847.34171007254281, 3000.86074447018018],
                    [3847.34171007254281, 2785.240077064262096],
                    [3260.34191304818205, 2785.240077064262096],
                    [3260.34191304818205, 2795.954148466309107]
                ]
            }
        },
        {
            "type": "Feature",
            "properties": {
                "Layer": "0",
                "SubClasses": "AcDbEntity:AcDbPolyline",
                "EntityHandle": "1A4"
            },
            "geometry": {
                "type": "LineString",
                "coordinates": [
                    [3611.469650131302842, 2846.845982610575902],
                    [3695.231030111376185, 2846.845982610575902],
                    [3695.231030111376185, 2785.240077064262096],
                    [3611.469650131302842, 2785.240077064262096],
                    [3611.469650131302842, 2846.845982610575902]
                ]
            }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

我希望实现以下操作data

  1. 将密钥替换EntityHandle …

python json geojson

1
推荐指数
1
解决办法
1万
查看次数

使用pixijs渲染多边形

我正在尝试在移动设备上显示超过 6000 个多边形。目前,我正在使用 d3.js 库在 Android WebView 中使用 SVG 路径来执行此操作。它有效,但我必须处理性能问题,当我拖动地图或缩放时,我的地图变得非常滞后。

我现在的想法是尝试用pixijs做同样的事情。我的数据最初来自 ESRI Shapefiles。我将这些 Shapefile 转换为 GeoJSON,然后转换为 SVG。我的顶点数组看起来像这样,我试图将其传递给 drawPolygon 函数

0:994.9867684400124 1:22.308409862458518 2:1042.2789743912592 3:61.07148769269074

但是当我尝试渲染这些多边形时,没有显示任何内容。这是我的代码:

        var renderer = PIXI.autoDetectRenderer(1800, 1800, { backgroundColor: 0x000000, antialias: true });
        document.body.appendChild(renderer.view);

        var stage = new PIXI.Container();
        var graphics = new PIXI.Graphics();

        var totalShapes = feat.features.length; 

        for (var i = 1; i <= totalShapes -1; i++) {

            var shape = feat.features[i];
            var geometry = shape.geometry.bbox;

            graphics.beginFill(0xe74c3c);
            graphics.drawPolygon([ geometry]);
            graphics.endFill();
            stage.addChild(graphics);
            renderer.render(stage);

         }
Run Code Online (Sandbox Code Playgroud)

有人可以帮助我或者建议我采用不同的方式吗?

svg polygon geojson pixi.js

1
推荐指数
1
解决办法
4252
查看次数

存储 GeoJson 点并在给定距离/半径内查找点 | NODEJS、Postgres、NestJs、TypeOrm

先感谢您。我在互联网上搜索了一个工作示例/文档,以获取存储位置点(经度、纬度)、查找两点之间的距离、查找给定距离内的点的方法。我正在使用 typeorm、nestjs、postgresql。

(我已经尝试过 Mariadb,但 St_distance_sphere 在那里不起作用,所以我要使用 postgresql)

这是我的实体

@ApiProperty({
    type: String,
    title: 'current_location',
    example: '{"type":"Point","coordinates":[28.612849, 77.229883]}',
  })
  @Index({ spatial: true })
  @Column({
    type: 'geometry',
    srid: 4326,
    nullable: true,
    spatialFeatureType: 'Point',
    transformer: {
      to: (v: Point) => {
        console.log(JSON.stringify(v));
        return eval(`ST_GeomFromGeoJSON(${JSON.stringify(v)})`);
      },
      from: (v: any) => {
        return { type: 'Point', coordinates: [v.x, v.y] } as Point;
      },
    },
  })
  current_location: string;
Run Code Online (Sandbox Code Playgroud)

似乎有太多的 postgres/postgis 文档,但对我的情况没有任何用处。任何帮助深表感谢。我已经坚持了一个多星期。

*注意:我不想使用 JSONB 数据类型,因为它的速度较慢。

postgresql geojson node.js typeorm nestjs

1
推荐指数
1
解决办法
673
查看次数