importing data from mysql

7 views
Skip to first unread message

Flavio Coelho

unread,
May 7, 2009, 7:32:42 AM5/7/09
to geodjango
Hello

I have a large map in a MySQL database (created with ogr2ogr)

I wanted to know how I can get that into a model(and table) compatible
with geodjango (with a multipolygon "geom" field).
mysql format has the geometry on a separate table.

Importing from shapefile is out of the question since the map contains
strings in iso-8859-1 on which LayerMapping had chocked before...

Flávio

Justin Bronn

unread,
May 7, 2009, 10:19:07 AM5/7/09
to geod...@googlegroups.com
Flavio Coelho wrote:
> Hello
>
> I have a large map in a MySQL database (created with ogr2ogr)
>
> I wanted to know how I can get that into a model(and table) compatible
> with geodjango (with a multipolygon "geom" field).
> mysql format has the geometry on a separate table.

If you have 'django.contrib.gis' in your INSTALLED_APPS, the `inspectdb`
management command is overridden and able to introspect spatial databases:

$ ./manage.py inspectdb

> Importing from shapefile is out of the question since the map contains
> strings in iso-8859-1 on which LayerMapping had chocked before...

You can specify the encoding of the strings in a shapefile using the
`encoding='iso-8859-1'` keyword argument. This is actually done in the
tutorial -- if it's still choking, then it may not be in iso-8859-1
after all.

Regards,
-Justin

Flavio Coelho

unread,
May 7, 2009, 10:37:07 AM5/7/09
to geod...@googlegroups.com


Ok I'll try  the layermapping way again specifyng the encoding. I 'd rather have the whole map in one table.

thanks,

--
---
Flávio Codeço Coelho

Flavio Coelho

unread,
May 8, 2009, 11:50:43 AM5/8/09
to geodjango
If I use inspectdb, I end up with three tables. None of them has a
Polygon field, though one has a GeometryField.


I found out that the GeometryColumns and spatialRefSys are not really
necessary

soI kept only the Municipios table and imported the data directly via
sql

thanks

Flávio
Reply all
Reply to author
Forward
0 new messages