gpt4 book ai didi

geojson - 如何导入 GeoJSON 文件以便在 Google 地球引擎代码编辑器中使用?

转载 作者:行者123 更新时间:2023-12-01 22:50:51 29 4
gpt4 key购买 nike

我已经使用 SQL 到 geoJSON 生成了我的数据库的一些兴趣点。

地理数据:

    {
"FeatureCollection" : [
{
"geometry" : {
"coordinates" : [
-45.927083,
-12.260889
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "626.46"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.916500,
-12.255944
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "565.04"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.949417,
-12.270361
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "631.47"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.958833,
-12.277361
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "591.85"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.942944,
-12.249889
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "644.67"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.930917,
-12.243611
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "644.67"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.871917,
-12.197139
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "574.60"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.866861,
-12.206417
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "574.60"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.967389,
-12.261889
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "592.50"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.973500,
-12.250639
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "592.50"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.962944,
-12.245444
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "621.60"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.952667,
-12.239778
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "592.50"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.931639,
-12.228528
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "574.60"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.908694,
-12.247472
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "557.20"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.918667,
-12.239139
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "644.50"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.897028,
-12.246000
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "557.20"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.906417,
-12.230472
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "64.50"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.895750,
-12.225028
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "644.50"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.927111,
-12.213750
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "564.90"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.917639,
-12.208750
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "564.90"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.897833,
-12.198444
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "584.00"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.881583,
-12.202233
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "574.60"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.876833,
-12.235306
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "574.60"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.867278,
-12.230306
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "574.60"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.856806,
-12.224889
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "574.60"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.861806,
-12.215611
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "574.60"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.887833,
-12.192806
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "12.60"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.877639,
-12.187917
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "564.90"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.941889,
-12.234611
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "644.50"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.887111,
-12.239889
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "644.50"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.907944,
-12.203361
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "591.70"
},
"type" : "Feature"
},
{
"geometry" : {
"coordinates" : [
-45.892722,
-12.208028
],
"type" : "Point"
},
"properties" : {
"grower" : "foo",
"name" : "bar",
"radius" : "574.60"
},
"type" : "Feature"
}
]
}

我想将此 geojson 导入我在 Google 地球引擎上的代码编辑器。查看文档 ( assets manager ),GEE 接受光栅图像、形状文件(.shp、shx、dbf、prj)形式的 Assets 。

此外,我发现通过融合表导入特征集合,但它仍然需要 shapefile。

我找到了一些 geojson 到 shapefile 转换器,但我需要一种方法将我的 geojson 直接导入 GEE 上的特征集合。这可能吗?

最佳答案

您还可以将 GeoJSON 几何对象直接导入到 JavaScript 或 Python API 中,例如,使用这种格式的 MultiPolygon:

feature_geometry = {
"type": "MultiPolygon",
'coordinates": [
[
[
[-120, 35],
[-120.001, 35],
[-120.001, 35.001],
[-120, 35.001],
[-120, 35]
]
]
]
}

两个 HashMap (即字典)与 GeoJSON 规范 (source) 相同:

{
"type": "MultiPolygon",
"coordinates": [
[
[
[-120, 35],
[-120.001, 35],
[-120.001, 35.001],
[-120, 35.001],
[-120, 35]
]
]
]
}

当然,您也可以从 GeoJSON 文件中读取此数据(显示 Python 示例):

import json
data = json.loads(geojson_file)

对于简单的 Python 包装器,可以使用 pygeoj 库,但 JSON 数据在 Python 和 JavaScript 中都能很好地处理。

关于geojson - 如何导入 GeoJSON 文件以便在 Google 地球引擎代码编辑器中使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46697419/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com