Opened 12 years ago
Closed 12 years ago
#22041 closed Uncategorized (invalid)
LayerMapError: Django cannot import shapefile into postgresql
| Reported by: | klopycira | Owned by: | nobody |
|---|---|---|---|
| Component: | Uncategorized | Version: | 1.6 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Unreviewed | |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
I am working on a web-based gis project using geodjango under django 1.6 framework. . I have using postgresql 9.1 and python 2.7
while following the tutorial on installing and making first apps in django, i have worked on the sample (world, as presented in tutorial) and it worked properly. As soon as i have created my own apps using srid=32651, I have this error:
LayerMapError: Could not retrieve geometry from feature
below are my codes, and i don't know i got my mistake. .
thanks in advance for helping out. .
cheers!
models.py
from django.db import models
from django.contrib.gis.db import models as gismodels
class Butuan_Parcel(gismodels.Model):
newpin = models.CharField(max_length=35)
geometry = gismodels.MultiPolygonField(srid=32651)
objects = gismodels.GeoManager()
def __unicode__(self):
return self.newpin
# Create your models here.
settings.py
import os
from django.contrib.gis.utils import LayerMapping
from models import Butuan_Parcel
bound_mapping = {
'newpin': 'NEWPIN',
'geometry': 'MULTIPOLYGON',
}
bound_shp = os.path.abspath(os.path.join(os.path.dirname(__file__),'data/parcels.shp'))
def run(verbose=True):
lm = LayerMapping(Butuan_Parcel, bound_shp, bound_mapping,
transform=False, encoding='iso-8859-1')
lm.save(strict=True, verbose=verbose)
load.py
import os
from django.contrib.gis.utils import LayerMapping
from models import Butuan_Parcel
bound_mapping = {
'newpin': 'NEWPIN',
'geometry': 'MULTIPOLYGON',
}
bound_shp = os.path.abspath(os.path.join(os.path.dirname(__file__),'data/parcels.shp'))
def run(verbose=True):
lm = LayerMapping(Butuan_Parcel, bound_shp, bound_mapping,
transform=False, encoding='iso-8859-1')
lm.save(strict=True, verbose=verbose)
This tracker is not meant as a support channel, please write to the GeoDjango mailing list for support.
https://groups.google.com/forum/#!forum/geodjango