1

I've been having issues visualising data from a shapefile in GeoDjango using OpenStreetMap. I believe it's some sort of a scale issue because of how it appears (as you can see in the screenshot of the admin interface).

I've stored the data in a PostGIS database and set up the model using django as advised in the documentation. Another interesting thing to note is that loading up the data using QGIS works perfectly and looks exactly like the shapefile. Any ideas as to what I should try next?

I'd also be happy to post any code if people need to see it but I am new to GIS stuff and don't quite know what anyone would need to see right away.

Screenshot of geodjango admin interface

  • Could you describe how you expected it to appear? Or provide a screenshot from QGIS where you say it "works perfectly?" It's not clear what the problem is. – Arthur Mar 21 '14 at 12:54
  • If a polygon is "missplaced" like that, it is likely to be related to the projection. In GeoDjango the default srid is 4326, if you were rendering your polygon with another projection in Qgis, that might be the cause for the difference. What is the projection of your shapefile? – yellowcap Mar 21 '14 at 13:28
  • The projection in QGIS is exactly the same(EPSG:4326 - WGS 84), it's just not rendering it correctly. Here's what it looks like in QGIS. – infinite code Mar 22 '14 at 23:12
1

So from what you describe I think you might just be interpreting the admin interface in the wrong way. When you set up a model in Django that contains a polygon field, such as

class MyModel(models.Model):
    Mpoly = models.MultiPolygonField()
    objects = models.GeoManager()

Then each model instance represents only one row from your shapefile or your DB table. When loading a shapefile, the parser will create many MyModel instances, one per row of your shapefile.

So my guess is that the admin screenshot you posted is the admin page for one such instance, which will only show one polygon from your table. The GeoDjango admin interface will not show you your entire layer on a map. If you are on the page of one instance, for example /admin/mymodel/23 then the polygon you see is the one corresponding one row in your DB.

In QGis, you access an entire table on a PostGIS database, which shows you all MyModel instances at once on the map. The attributes of each geometry are then the other model fields you might have in your model definition.

  • You're exactly right. I had a look at the data and I was definitely looking at it the wrong way. Any suggestions on how I can set up my views so I can visualise the entire table at the same time? – infinite code Mar 25 '14 at 7:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.