Putting any Shape file to DB

91 views
Skip to first unread message

Fernando

unread,
Sep 28, 2011, 1:59:48 PM9/28/11
to geod...@googlegroups.com
Hi,

I'm initiating in webGIS in general and decide to choose GeoDjango. So this is a newbie question.

I'm trying to create a system to receive a ShapeFile and import to DB.

First I try use LayerMapping, then I realize that I couldn't pass values of my system that not exists in the shapefile.
So I decide to use DataSources to get just the poilygon coordenates and save my data.
But in very different ways, allways a received an type of data error.
One example bellow:

cannot set Orcamento GeometryProxy with value of type: <class 'django.contrib.gis.geos.polygon.Polygon'>

The important data of my model:
    mpoly = models.MultiPolygonField()
    objects = models.GeoManager()

The code to save: 
 ds = DataSource(file_full)
                    for layer in ds:
                        print layer.geom_type
                        for polyg in layer.get_geoms(geos=True):
                            #poly = GEOSGeometry(polyg, srid=4329)
                            orc = Orcamento(session_id = session_id, mpoly = polyg)
                            orc.save()


the OGRINFO for the SHAPEFILE that I create to test
ogrinfo -so teste.shp teste
INFO: Open of `teste.shp'
      using driver `ESRI Shapefile' successful.

Layer name: teste
Geometry: 3D Polygon
Feature Count: 1
Extent: (-43.827768, -20.346558) - (-43.817162, -20.336426)
Layer SRS WKT:
GEOGCS["GCS_WGS_1984",
    DATUM["WGS_1984",
        SPHEROID["WGS_1984",6378137,298.257223563]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.017453292519943295]]
Name: String (80.0)
Descriptio: String (80.0)


Can I get a conclusion that I can't create a system to put any kind of shape file (with a Polygon layer) to my system withouth a standard?

Thanks in advance,

Fernando G. Norte
BHte - MG - Brazil
cel: +55 31 9119 8814
-------------------------
MSN e Gtalk # fno...@gmail.com

Tonton

unread,
Nov 2, 2011, 7:01:25 AM11/2/11
to geod...@googlegroups.com
hello to import shp in postgres i use shp2pgsql

i load with formfile  and make  sqlfile to create table with my shapfile into

regards
T.

--
You received this message because you are subscribed to the Google Groups "geodjango" group.
To post to this group, send email to geod...@googlegroups.com.
To unsubscribe from this group, send email to geodjango+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/geodjango?hl=en.

Paolo Corti

unread,
Nov 2, 2011, 9:58:59 AM11/2/11
to geod...@googlegroups.com
On 02/nov/2011, at 12:01, Tonton <to.t...@gmail.com> wrote:

> hello to import shp in postgres i use shp2pgsql
>
> i load with formfile and make sqlfile to create table with my shapfile into
>
> regards
> T.
>

Another very good tool is the ogr2ogr command,
Included in GDAL

Best regards
P

Reply all
Reply to author
Forward
0 new messages