使用以下查询成功插入一条记录:
INSERT INTO test.geoPSGC (PK,PSGC,NAME,COORDINATES) VALUES ("PH042103059","PH042103059","P.F. ESPIRITU VIII", GEOJSON('{"type": "Polygon", "coordinates": [[[120.963819085,14.4360609570001],[120.963508642,14.437767122],[120.963132639,14.4396434060001],[120.963030111,14.4401597790001],[120.962205408,14.4399052410001],[120.960393097,14.439447073],[120.960260737,14.4401495980001],[120.96018129,14.440132872],[120.959486942,14.439986693],[120.959097233,14.4411254360001],[120.959038955,14.441300109],[120.960790176,14.441788822],[120.960572028,14.4424181910001],[120.959700188,14.4445419810001],[120.960098399,14.4447199690001],[120.960774416,14.4450736870001],[120.960692088,14.4452229070001],[120.960470831,14.4456654210001],[120.960321611,14.445969007],[120.958550232,14.4448707610001],[120.958129094,14.443015749],[120.955905609,14.4426806610001],[120.955608883,14.443570838],[120.955346395,14.4434795380001],[120.955289332,14.4437420260001],[120.954969781,14.443696376],[120.954889894,14.4440045150001],[120.954225114,14.443719201],[120.953954066,14.443696376],[120.952336035,14.444176962],[120.952255088,14.443998277],[120.953521745,14.443688057],[120.953902021,14.4424971950001],[120.954722615,14.442737369],[120.954912753,14.4421769630001],[120.955873449,14.442287043],[120.956533927,14.440325622],[120.956223702,14.440255571],[120.95590347,14.440245564],[120.955142919,14.4402956],[120.954782659,14.440255571],[120.954332332,14.4400954550001],[120.954452419,14.439054701],[120.953801948,14.438904592],[120.952911303,14.438774498],[120.952965697,14.438500543],[120.952985959,14.4382396770001],[120.953011179,14.4381358630001],[120.953277921,14.4369847450001],[120.953318707,14.4368087330001],[120.956736645,14.436828264],[120.956768379,14.4362091220001],[120.956779247,14.435895783],[120.956804391,14.4355445270001],[120.956772893,14.435371087],[120.956809539,14.4351651270001],[120.956836543,14.434532458],[120.956863741,14.4340464310001],[120.956467101,14.4338641910001],[120.9557208,14.4338163350001],[120.955738353,14.4330264620001],[120.955744235,14.4323139710001],[120.957669155,14.4323067990001],[120.957844682,14.4326051960001],[120.96010627,14.4329594650001],[120.961732768,14.4327991060001],[120.962557471,14.4326845640001],[120.964088989,14.4329410820001],[120.96407482,14.433125068],[120.964044954,14.433513331],[120.964071138,14.433868956],[120.964138908,14.434272455],[120.964139531,14.4343794550001],[120.963928361,14.435506225],[120.963819085,14.4360609570001]]]}'));
Run Code Online (Sandbox Code Playgroud)
但在使用 Aerospike Rest Client v1.10.4(最新)时抛出错误“无法识别的令牌‘GEOJSON’”
请求正文:
{
"PSGC": "PH042103059",
"NAME": "P.F. ESPIRITU VIII",
"COORDINATES": GEOJSON('{"type": "Polygon", "coordinates": [[[120.963819085,14.4360609570001],[120.963508642,14.437767122],[120.963132639,14.4396434060001],[120.963030111,14.4401597790001],[120.962205408,14.4399052410001],[120.960393097,14.439447073],[120.960260737,14.4401495980001],[120.96018129,14.440132872],[120.959486942,14.439986693],[120.959097233,14.4411254360001],[120.959038955,14.441300109],[120.960790176,14.441788822],[120.960572028,14.4424181910001],[120.959700188,14.4445419810001],[120.960098399,14.4447199690001],[120.960774416,14.4450736870001],[120.960692088,14.4452229070001],[120.960470831,14.4456654210001],[120.960321611,14.445969007],[120.958550232,14.4448707610001],[120.958129094,14.443015749],[120.955905609,14.4426806610001],[120.955608883,14.443570838],[120.955346395,14.4434795380001],[120.955289332,14.4437420260001],[120.954969781,14.443696376],[120.954889894,14.4440045150001],[120.954225114,14.443719201],[120.953954066,14.443696376],[120.952336035,14.444176962],[120.952255088,14.443998277],[120.953521745,14.443688057],[120.953902021,14.4424971950001],[120.954722615,14.442737369],[120.954912753,14.4421769630001],[120.955873449,14.442287043],[120.956533927,14.440325622],[120.956223702,14.440255571],[120.95590347,14.440245564],[120.955142919,14.4402956],[120.954782659,14.440255571],[120.954332332,14.4400954550001],[120.954452419,14.439054701],[120.953801948,14.438904592],[120.952911303,14.438774498],[120.952965697,14.438500543],[120.952985959,14.4382396770001],[120.953011179,14.4381358630001],[120.953277921,14.4369847450001],[120.953318707,14.4368087330001],[120.956736645,14.436828264],[120.956768379,14.4362091220001],[120.956779247,14.435895783],[120.956804391,14.4355445270001],[120.956772893,14.435371087],[120.956809539,14.4351651270001],[120.956836543,14.434532458],[120.956863741,14.4340464310001],[120.956467101,14.4338641910001],[120.9557208,14.4338163350001],[120.955738353,14.4330264620001],[120.955744235,14.4323139710001],[120.957669155,14.4323067990001],[120.957844682,14.4326051960001],[120.96010627,14.4329594650001],[120.961732768,14.4327991060001],[120.962557471,14.4326845640001],[120.964088989,14.4329410820001],[120.96407482,14.433125068],[120.964044954,14.433513331],[120.964071138,14.433868956],[120.964138908,14.434272455],[120.964139531,14.4343794550001],[120.963928361,14.435506225],[120.963819085,14.4360609570001]]]}'))
}
Run Code Online (Sandbox Code Playgroud) 我有一个 BigQuery 表:
其中geometry列的类型为GEOGRAPHY:
我想将此表导出为 GeoJSON 格式。我知道如何将表导出为简单的 JSON(请参阅此处),但这不是我的目标。我还知道如何geometry以 GeoJSON 形式获取列的各个行:
问题是它适用于单独的行,而不是整个列,也不是表。
预期输出:
{
"type": "FeatureCollection",
"features": [
{ "type": "Feature", "properties": { "description": "aaa" }, "geometry": { "type": "Point", "coordinates": [ 60.0, 10.0 ] } },
{ "type": "Feature", "properties": { "description": "bbb" }, "geometry": { "type": "Point", "coordinates": [ 65.0, 15.0 ] } }
]
}
Run Code Online (Sandbox Code Playgroud)
如何从 BigQuery 表中获取此 GeoJSON 字符串或文件?
我们有一个默认的 VPC。尝试运行数据流作业。初始步骤(读取文件)设法处理 1/2 步骤。获取JOB_MESSAGE_ERROR: SDK harness sdk-0-0 disconnected错误消息,但日志中没有其他内容。已尝试设置角色和 vpc 防火墙规则。
我想使用 Geobeam 图像 (Apache Beam Python 3.9 SDK 2.41.0) 运行数据流作业。我对工作的定义如下:
def run(pipeline_args, known_args):
import apache_beam as beam
from apache_beam.io.gcp.internal.clients import storage
from apache_beam.options.pipeline_options import PipelineOptions
from geobeam.io import GeoJSONSource, filebasedsource
from geobeam.fn import format_record, make_valid, filter_invalid
pipeline_options = PipelineOptions([
] + pipeline_args)
with beam.Pipeline(options=pipeline_options) as p:
(p
| beam.io.Read(GeoJSONSource(known_args.gcs_url, encoding='utf-8'))
| 'FilterCords' >> beam.Filter(lambda x: len(x[-1]["coordinates"]) > 1)
| 'MakeValid' >> beam.Map(make_valid)
| 'FilterInvalid' >> beam.Filter(filter_invalid) …Run Code Online (Sandbox Code Playgroud) 我有两个具有多对多关系的模型,我试图通过使用Django REST框架返回一些geojson.我想要返回的数据是pub_date和坐标(由GeoDjango中的PointField表示).每当我尝试返回geojson时,我都会收到错误Field name 'city' is not valid for model 'Article'.我是django/geodjango的新手,这是我第一次使用Django REST Framework.我已经完成了文档,但无法解决我出错的地方(或者甚至可能从哪里开始).
这是我的模型和序列化器.
models.py:
class Location(models.Model):
city = models.CharField(max_length=200)
country = models.CharField(max_length=200)
continent = models.CharField(max_length=200)
point = models.PointField(srid=4326)
objects = models.GeoManager()
def __unicode__(self):
return u'%s' % (self.point)
class Meta:
db_table = 'location'
class Article(models.Model):
authors = models.ManyToManyField(Author)
locations = models.ManyToManyField(Location, related_name='places')
article_title = models.CharField(max_length=200, unique_for_date="pub_date")
pub_date = models.DateTimeField('date published')
article_keywords = ArrayField(ArrayField(models.CharField(max_length=20, blank=True), size=10), size=10,)
title_id = models.CharField(max_length=200)
section_id = models.CharField(max_length=200)
def __unicode__(self):
return u'%s %s %s' % …Run Code Online (Sandbox Code Playgroud) 我已经使用谷歌地图Javascript API几个星期了.在将geoJSON的属性添加到地图并成为地图的特征之后,我一直无法访问该属性.
例如,假设我有这个示例geoJSON
var geo = {"type":"FeatureCollection","features":[
{"type":"Feature","id":"country","properties":
{"name":"ExampleCountry"},"geometry": {exampleGeometry}}
]};
Run Code Online (Sandbox Code Playgroud)
假设我加载了geoJSON并想要访问我刚添加的功能的id属性.在这种情况下都feature.id不起作用feature.getProperty('id').通过调试,我发现我可以通过访问'id'属性feature.F.该解决方案工作正常数周,但无论出于何种原因,上周它停止工作.我必须使用feature.K访问ID属性.
var mapOptions = {
center: { lat: -34.397, lng: 150.644},
zoom: 8
};
map = new google.maps.Map(document.getElementById('map-canvas'), {mapOptions});
map.data.loadGeoJson(geo);
map.data.forEach(function(feature) {
//Used to Work, randomly stopped working last week (feature.F is undefined)
var id = feature.F;
//New Solution
var id = feature.K;
});
Run Code Online (Sandbox Code Playgroud)
这似乎不是一个永久的解决方案.有谁知道这怎么可能发生?
我在数据层中的信息居中和放大方面遇到了麻烦.我试图使用这里建议的方法:stackoverflow问题:在Google Maps API v3中缩放到geojson多边形边界.我最初还是放大到他所在的地方,有些地方在贝克岛附近的太平洋上.我正在从服务器加载GeoJson对象,它正确显示.我的代码:
function loadMap () {
var m = document.getElementById("googleMap");
var mapProp = {
disableDoubleClickZoom: true,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
var map = new google.maps.Map(m, mapProp);
map.data.addListener('addfeature', function(e) {
var bounds = new google.maps.LatLngBounds();
processPoints(e.feature.getGeometry(), bounds.extend, bounds);
map.setCenter(bounds.getCenter());
map.fitBounds(bounds);
});
var geoJsonObject = {
type: "FeatureCollection",
features: [
{
type: "Feature",
properties: {},
geometry: {
type: "MultiPolygon",
coordinates: [
[[[-86.80795499999999, 36.146389], [-86.80605800006222, 36.14733499995285], [-86.806471, 36.147928], [-86.80836699994975, 36.14697700000941], [-86.80795499999999, 36.146389]]],
[[[-86.803842, 36.143921999999996], [-86.803761, 36.144005], [-86.80374600001942, 36.1441770000485], [-86.804918, 36.1458], …Run Code Online (Sandbox Code Playgroud) 他们似乎以同样的方式工作,但我无法弄清楚差异.
我需要使用leaflet.js将地图添加到我的网站。该站点具有一个管理视图,管理员可以在其中添加标记,并向每个标记添加描述和图像。
我使用了leaflet.draw插件,并在创建事件上尝试更新event.layer.toGeoJSON()用来添加一些属性(例如图像和文本)的GeoJSON对象,但是没有运气。
谁可以帮我这个事?
var osmUrl = 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
osmAttrib = '© <a href="http://openstreetmap.org/copyright">OpenStreetMap</a> contributors',
osm = L.tileLayer(osmUrl, {
maxZoom: 18,
attribution: osmAttrib
});
map = new L.Map('map', {
layers: [osm],
center: new L.LatLng(31.9500, 35.9333),
zoom: 15
}),
drawnItems = L.geoJson().addTo(map);
map.addControl(new L.Control.Draw({
edit: {
featureGroup: drawnItems
}
}));
map.on('draw:created', function(event) {
var layer = event.layer;
var json = event.layer.toGeoJSON();
json.properties.desc = null;
json.properties.image = null;
drawnItems.addLayer(L.GeoJSON.geometryToLayer(json));
addPopup(layer);
});
function addPopup(layer) {
var content = '<input id="markerDesc" type="text"/ onblur="saveData(layer);">';
layer.bindPopup(content).openPopup(); …Run Code Online (Sandbox Code Playgroud) 所以我有一个geojson对象,它具有:
"features" : [{"properties": {"rank": 10}},{"properties": {"rank": 2}}]
Run Code Online (Sandbox Code Playgroud)
等等.我想找到最低等级并使用min方法.所以我尝试过这样的事情:
features = geojson["features"]
min(features["properties"]["rank"])
Run Code Online (Sandbox Code Playgroud)
然后:
features = geojosn["features"]["properties"]["rank"]
min(features)
Run Code Online (Sandbox Code Playgroud)
并得到了这两个:
TypeError:List索引必须是切片的整数,而不是str
我究竟做错了什么?任何帮助将不胜感激,谢谢!
我正在使用Leaflet.js在地图中显示geojson文件,我有以下代码:
// Set the map and the geojson as pointed in the tutorials
var geojsonLayer = new L.GeoJSON(null, {
onEachFeature: function (feature, layer) {
if (feature.properties) {
var popupString = '<div class="popup">';
for (var k in feature.properties) {
var v = feature.properties[k];
popupString += k + ': ' + v + '<br />';
}
popupString += '</div>';
layer.bindPopup(popupString, {
maxHeight: 200
});
}
}
});
map.addLayer(geojsonLayer);
L.control.layers({'Road': road_layer, 'Satellite': satellite_layer}, {'GeoJSON': geojsonLayer}).addTo(map);
//...
// Load file and get …Run Code Online (Sandbox Code Playgroud) geojson ×10
google-maps ×2
javascript ×2
leaflet ×2
python ×2
aerospike ×1
apache-beam ×1
django ×1
geodjango ×1
gis ×1
json ×1
leaflet.draw ×1
min ×1
rest-client ×1
sql ×1
zooming ×1