Re: Converting GeometryField to MultiPolygon using GeoDjango?

2018-06-13 Thread Jani Tiainen
Hi.

I usually do data cleanups with QGIS tool which has excellent tools to
manipulate data. And it's relatively fast.

Of course if you need to import data more regular basis QGIS might not be
an option.

ke 13. kesäk. 2018 klo 21.30 Jack  kirjoitti:

> See original question on Stack Overflow
> <https://stackoverflow.com/questions/50841538/converting-geometryfield-to-multipolygon-using-geodjango>
>  for
> better formating.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/8b8f53c5-2e53-4ec8-b2e6-7c7ec18ed5fe%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/8b8f53c5-2e53-4ec8-b2e6-7c7ec18ed5fe%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91oeDgwMGQ8Q1E7fk5K9-Pw1k8vMjBfK9sisSY94Z1%3D-WbA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Converting GeometryField to MultiPolygon using GeoDjango?

2018-06-13 Thread Jack
See original question on Stack Overflow 
<https://stackoverflow.com/questions/50841538/converting-geometryfield-to-multipolygon-using-geodjango>
 for 
better formating.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8b8f53c5-2e53-4ec8-b2e6-7c7ec18ed5fe%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Converting GeometryField to MultiPolygon using GeoDjango?

2018-06-13 Thread Jack
I am trying to add a bunch of school boundary files into the database.  The 
boundary files are inconsistent.  They are processed by `DataSource` as 
either `Polygon`, `MultiPolygon`, or `GeometryCollection`.

Converting `Polygon` into `MultiPolygon` is fairly simple using this 
solution 
(https://gis.stackexchange.com/questions/13498),
 
but the conversion does not work for `GeometryCollection`.

class School(models.Model):
boundaries = models.MultiPolygonField()

---

from django.contrib.gis.geos import Polygon, MultiPolygon
from django.contrib.gis.geos.collections import GeometryCollection

ds = DataSource('school_boundaries.aspx')
feature = ds[0][0]
geom_geos = feature.geom.geos
if isinstance(geom_geos, Polygon):
geom_geos = MultiPolygon(geom_geos)
elif isinstance(geom_geos, GeometryCollection):
geom_geos = MultiPolygon(GeometryCollection)  #This does not work
school = School(boundaries = geom_geos)
school.save()

Is there some way to convert `GeometryField` to `MultiPolygon` in GeoDjango?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9fa3df23-bc41-4ea4-a766-d68525065766%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.