You should seriously take a look at the ogr2ogr command-line program
that comes with GDAL. It can go directly from PostGIS to shapefile (or
CSV, KML, GPX, etc.).
> While it's possible I'm overlooking some obvious documentation, or, at
> the other extreme, making some ridiculous pony request -- I'm curious
> whether there might be a more direct method for dumping things out.
Yes there is a more direct method, and Dane has made django-shapes for
this purpose (as Josh pointed out). However the end game would be to
extend the existing GDAL (OGR) API within GeoDjango to support
DataSource creation. For a while now I've been wrestling in my mind how
the API should look and think it should be done via a `create` class method:
ds = DataSource.create('shapefile', '/path/to/shp', ...)
The first argument is the driver type (or Driver instance) and the
second argument is the path (or equivalent) to the data. The hard
part is figuring out what goes in the `...`. Either a dict (which has
no ordering) or a tuple of field names and field types is necessary.
Thus, I'm open to suggestions on how this should look -- just keep in
mind I want to be able to support creation of OGR data sources
generally, and just not shapefiles.
-Justin
I've just done this kind of thing, thanks to the help of Justin Bronn. I
works fine for shapefile, MapInfo tab files being a little bit more
tricky (multiple geometry types in layers...)
But it does the job : upload a zipfile, unzip, get the shapefile, build
a model from its fields (layermapping), create the table and populates
it. The model is then accessible from the admin site. BUT I stil have
pretty buggy behaviours on production server where MaxRequestPerChild is
high for performance reasons. The model disappears and reappers randomly :-(
I can share that approach if you wish.
Regards
Guillaume
Flávio Codeço Coelho a écrit :
Flávio Codeço Coelho a écrit :
> Hi Guillaume,
>
> Yes, I am interested in seeing what you have done. Do you plan to make
> the code available as open-source?
Sure, but as more than half of the code comes from Justin, we should ask
him first.
Ariel Mauricio Nunez Gomez a écrit :
Guillaume
Ariel Mauricio Nunez Gomez a écrit :
> mod_wsgi
>
> On Fri, Mar 13, 2009 at 10:46 AM, Guillaume Sueur
> <guillau...@neogeo-online.net
> <mailto:guillau...@neogeo-online.net>> wrote:
>
>
> sure !
> do you use mod_python as well ?
>
> Ariel Mauricio Nunez Gomez a écrit :
> > I also have developed that functionality(On the fly model creation), I
> > would be very interested in comparing them and trying to make sure it
> > runs as buggyless as possible.
> >
> > Best,
> >
> > Ariel
> >
> > On Fri, Mar 13, 2009 at 8:58 AM, Flávio Codeço Coelho
> > <fcco...@gmail.com <mailto:fcco...@gmail.com>
> <mailto:jbr...@gmail.com <mailto:jbr...@gmail.com>>
Basically, you need a way to persist the dynamically created models
somehow. There's two approaches I can think of: (i) actually write out
models to models.py or (ii) persist the models information in the
database via another model, and set module attributes dynamically.
> Sure, but as more than half of the code comes from Justin, we
> should ask him first.
Here's the app, in it's incomplete state:
http://geodjango.org/hg/dyngeo/
I'll try and work on it some more, and integrate changes of others, but
it'll have to take a backseat to the priority of getting 1.1 out.
-Justin
Basically, you need a way to persist the dynamically created models
somehow. There's two approaches I can think of: (i) actually write out
models to models.py or (ii) persist the models information in the
database via another model, and set module attributes dynamically.
Ariel Mauricio Nunez Gomez a écrit :
>
> --~--~---------~--~----~------------~-------~--~----~
> 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