django--LayerMapError:无法从特征检索几何 [英] django--LayerMapError: Could not retrieve geometry from feature

查看:80
本文介绍了django--LayerMapError:无法从特征检索几何的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在django中运行我的应用程序时出现此错误。它说
LayerMapError:无法从要素中检索几何

i got this error when i run my apps in django..it says LayerMapError: Could not retrieve geometry from feature

我已经在PostgreSQL中创建了空间数据库(遵循 [本教程]

i have already created spatial database in postgresql (following the tutorial given in [this tutorial] )

下面是我的load.py代码
和我的models.py
我的应用程序名称为Application_Files
,模块名称为mod_parcel

below is my load.py code and my models.py my app name is Application_Files and my module name is mod_parcel

import os

from django.contrib.gis.utils import LayerMapping
from models import mod_parcel

bound_mapping = {
'NEWPIN' : 'NEWPIN',
'DIST_NO' : 'DIST_NO',
'TDNO' : 'TDNO',
'PIN' : 'PIN',
'OWNERFULLN': 'OWNERFULLN',
'AREA' : 'AREA',
'OCT_TCNO' : 'OCT_TCNO',
'BARANGAY' : 'BARANGAY',
'CLASS' : 'CLASS',
'MRKTVAL' : 'MRKTVAL',
'ASSDVAL' : 'ASSDVAL',
'Geometry' : 'Geometry',
}

bound_shp = os.path.abspath(os.path.join(os.path.dirname(__file__), 'DATA/parcel/parcels.shp'))

def run(verbose=True):
lm = LayerMapping(mod_parcel, bound_shp, bound_mapping,
                  transform=False, encoding='iso-8859-1')
lm.save(strict=True, verbose=verbose)

另一个代码在这里。

from django.contrib.gis.db import models
from django.contrib.gis.db import models as gismodels

class mod_parcel(gismodels.Model):

NEWPIN = gismodels.CharField(max_length=35)
DIST_NO = gismodels.IntegerField()
TDNO = gismodels.CharField(max_length=254)
PIN = gismodels.CharField(max_length=254)
OWNERFULLN = gismodels.CharField(max_length=254)
AREA = gismodels.FloatField()
OCT_TCNO = gismodels.CharField(max_length=254)
BARANGAY = gismodels.CharField(max_length=254)
CLASS = gismodels.CharField(max_length=254)
MRKTVAL = gismodels.FloatField()
ASSDVAL = gismodels.FloatField()
Geometry = gismodels.MultiPolygonField(srid=32651)
objects = gismodels.GeoManager()

def __unicode__(self):
return self.NEWPIN

我真的不知道在哪里修改代码或其他内容。 。只是我是django的新手,所以我无法弄清楚..任何人都可以分享与此问题有关的东西吗?

I dont really know where to modify codes or something. . its just that i am a newbie in django and i cannot figure this out.. can any share something relevant to this problem??

推荐答案

该错误是在映射中的几何设置中。
期望使用OGRGeomType,例如POINT,POLYGON...。

The error is in your geometry setting in the mapping. It is expecting an OGRGeomType such as POINT, POLYGON....

这篇关于django--LayerMapError:无法从特征检索几何的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆