我有两个geoJson图层被加载 - 这两个图层是用于测试目的的相同数据,但是从两个不同的json文件中提取.当我在图层控制器中打开和关闭图层时,图层的绘制顺序会发生变化.
任何想法为什么会这样?
我已将我的代码放入JSFiddle:http://jsfiddle.net/lprashad/ph5y9/10/,JS如下:
//styling for watersheds_copy
var Orange = {
"color": "#ff7800",
"weight": 5,
"opacity": 0.65
};
var Water_Orange = L.geoJson(watersheds_copy, {
style: Orange
});
Water_Orange.addData(watersheds_copy);
//these are blue
var Water_blue = L.geoJson(watersheds, {});
Water_blue.addData(watersheds);
//This sets the inital order - last in layer list being on top. Except minimal - tile layer is always on bottom
var map = L.map('map', {
center: [41.609, -74.028],
zoom: 8,
layers: [minimal, Water_Orange, Water_blue]
});
var baseLayers …Run Code Online (Sandbox Code Playgroud) 这个问题部分回答了我的问题.作者使用类似的json结构..
我的问题:如何在嵌套对象中允许嵌套数组?我有一个Contribution模特has_many Features.我正在尝试创建GeoJSON多边形.在coordinates保持为空
这是我发送的JSON
{
"contribution": {
"features_attributes": [
{
"geojson": {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
7.263336181640625,
52.07190953840937
],
[
7.263336181640625,
52.135173926548894
],
[
7.404785156249999,
52.135173926548894
],
[
7.404785156249999,
52.07190953840937
],
[
7.263336181640625,
52.07190953840937
]
]
]
}
}
}
],
"title": "324",
"description": "23"
}
}
Run Code Online (Sandbox Code Playgroud)
目前我的许可证代码如下:
params.require(:contribution).permit(
:title,
:description,
features_attributes: [
{ geojson: [
:type,
{ geometry: [
:type,
#{ coordinates: [] } …Run Code Online (Sandbox Code Playgroud) 在 Google Big Query 中加载以下 geojson 文件的最佳方式是什么?
http://storage.googleapis.com/velibs/stations/test.json
我在 Google Storage 上有很多这样的 json 文件(更大),我无法下载/修改/上传它们(这将需要很长时间)。请注意,该文件不是换行符分隔的,所以我猜它需要在线修改。
谢谢大家。
我试图在 Python 中的 folium 地图中显示以下 geojson 文件,但它只显示一个没有任何数据的空地图。
以下是我尝试过的步骤:
我尝试使用下面的 python 代码,但没有显示任何内容。
我使用相同的代码尝试了下面 github 存储库中的其他 geojson 文件,并且数据显示没有任何问题,所以看起来我的 python 代码没问题
我在 github 和Mapshaper中打开了“census_tracts_2010.geojson”文件,数据显示完美,没有任何问题,所以看起来 geojson 文件没有损坏
谁能告诉我如何修复它?
Geojson 文件: https://github.com/dwillis/nyc-maps/blob/master/census_tracts_2010.geojson
Python代码:
import folium
m = folium.Map(location=[40.66393072,-73.93827499], zoom_start=13)
m.choropleth(geo_path="census_tracts_2010.geojson")
m.save(outfile='datamap.html')
Run Code Online (Sandbox Code Playgroud)
多谢!
我希望在地图上创建一个区域,并能够自动确定点(坐标)是否在该区域内。在本示例中,我使用整个美国的 geojson 文件和纽约市的坐标。
Geojson: https: //github.com/johan/world.geo.json
我已经阅读了 shapely 文档,只是不明白为什么我的结果返回 False。任何帮助将非常感激。
import json
from shapely.geometry import shape, GeometryCollection, Point
with open('USA.geo.json', 'r') as f:
js = json.load(f)
point = Point(40.712776, -74.005974)
for feature in js['features']:
polygon = shape(feature['geometry'])
if polygon.contains(point):
print ('Found containing polygon:', feature)
Run Code Online (Sandbox Code Playgroud)
我希望打印包含的坐标,但没有打印任何内容。
我希望在不同的层中使其颜色不同,因此请使用 style_function,如下所示:
style1 = {'fillColor': '#228B22', 'lineColor': '#228B22'}
style2 = {'fillColor': '#00FFFFFF', 'lineColor': '#00FFFFFF'}
test1=gpd.read_file('file2.geojson')
folium.GeoJson(test1,name='test1',style_function=lambda x:style).add_to(mainmap)
test2=gpd.read_file('file1.geojson')
folium.GeoJson(test2,name='test2', style_function=lambda x:style2).add_to(mainmap)
Run Code Online (Sandbox Code Playgroud)
不过上线后不起作用,仍然是默认的蓝色。
我想在我的地理地图上创建六边形,并希望保留 shapefile/geojson 指定的数字边界。如何使用 uber 的 h3 python 库来做到这一点?
我对 shapefile 或任何其他地理数据结构不熟悉。我对 python 最满意。
我有一张包含多个多边形的地图。多边形需要在用户单击/拖动时移动/更新。我想要的功能与此示例相同:https ://www.mapbox.com/mapbox-gl-js/example/drag-a-point/
我想让多边形像 mousedown 上的点示例一样可拖动,能够在地图上移动它,在整个事件中更新多边形节点的 x/y 坐标,但在整个拖动过程中保持 geojson 大小不变。
Mapbox 上的点教程效果很好,但我不确定如何使其与多边形一起使用。
所以我想在 javascript 中合并相邻的多边形,这就是我在代码中实际拥有的:
我想删除内部描边但保留边框描边。
所以我想从这里开始:
对此:
我想保留巴黎的洞 - 我可以定义哪些多边形必须分组,但我无法将它们与以下代码合并:
var map = L.map('map', {
center: [46.52863469527167, 2.43896484375],
zoom: 6,
maxZoom: 18,
minZoom: 7
});
$http.get("france.json").then(function (response) {
$scope.communeFr = response.data.features
$http.get(apiult).then(function (response) {
$scope.showCommune = response.data.Liste
$scope.communeFr.map(x => {
x.show = false
for (let i = 0; i < $scope.showCommune .length; i++) {
if (x.properties.insee == $scope.showCommune[i].insee) {
x.show = true
return
}
}
})
L.geoJson($scope.communeFr, {
filter: function (feature, latlng) {
return feature.show
}
}).addTo(map);
});
});
Run Code Online (Sandbox Code Playgroud)
更新 - …
我想从 geojson 文件导入一些航点/标记。然后确定所有点的质心。我的代码计算每个点的质心,而不是该系列中所有点的质心。如何计算系列中所有点的质心?
import geopandas
filepath = r'Shiloh.json'
gdf = geopandas.read_file(filepath)
xyz = gdf['geometry'].to_crs('epsg:3587')
print(type(xyz))
print(xyz)
# xyz is a geometry containing POINT Z
c = xyz.centroid
# instead of calculating the centroid of the collection of points
# centroid has calculated the centroid of each point.
# i.e. basically the same X and Y data as the POINT Z.
Run Code Online (Sandbox Code Playgroud)
print(type(xyz)) 和 print(xyz) 的输出
<class 'geopandas.geoseries.GeoSeries'>
0 POINT Z (2756810.617 248051.052 0.000)
1 POINT Z (2757659.756 247778.482 0.000)
2 POINT …Run Code Online (Sandbox Code Playgroud)