Geodjango:从OSGB_1936导入数据,在WGS84中显示?

发布于 2024-09-11 14:41:59 字数 548 浏览 1 评论 0 原文

我在 PostGIS 数据库中保存了一些多边形数据,投影 SRID 为 27700。

geom = models.MultiPolygonField(srid=27700)

我想在 OpenStreetMap 上显示形状,即 SRID 900913(我认为?)。

所以,有两个问题:

  1. 如何将下面的代码更改为 具有正确 SRID 的输出 打开街道地图?
  2. 我怎样才能改变 下面的 Django 代码给我一个很好的 json 对象,准备显示为 多边形?
area = get_object_or_404(soa.objects, code=my_code)
polygon = area.geom
return render_to_response('area.html', { 'area': area }, context_instance = RequestContext(request))

如果这个问题没有意义,我很抱歉 - 我对 GeoDjango 还很陌生。

I have some polygon data saved in a PostGIS database with projection SRID 27700.

geom = models.MultiPolygonField(srid=27700)

I want to display the shapes on OpenStreetMap, i.e. with SRID 900913 (I think?).

So, two questions:

  1. How do I change the code below to
    output with the right SRID for
    OpenStreetMap?
  2. How can I change the
    Django code below to give me a nice json
    object, ready to display as a
    polygon?
area = get_object_or_404(soa.objects, code=my_code)
polygon = area.geom
return render_to_response('area.html', { 'area': area }, context_instance = RequestContext(request))

Apologies if this question doesn't make sense - I'm pretty new to GeoDjango.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

美人骨 2024-09-18 14:41:59

对于 GeoDjango,使用 transform 更改几何图形的投影,以及 jsonwkt 用于输出。它应该很简单:

polygon.transform(900913)
return render_to_response('area.html', {'area': area, 'polygon': polygon.json})

json 方法将为您提供 GeoJSON;如果您愿意,可以使用 wkt。像 OpenLayers 这样的地图 API 可以处理其中任何一个。

With GeoDjango, use transform to change a geometry's projection, and json or wkt for output. It should be as simple as:

polygon.transform(900913)
return render_to_response('area.html', {'area': area, 'polygon': polygon.json})

json method will give you GeoJSON; you can use wkt if you prefer. A map API like OpenLayers will handle either.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文