Can i be able to plot a points on maps with geodjango? i figured i can plot polygons on a map but struggling to plot points is it possible? if it is how do i do it or help with a link to information where i can find how to do that

184 views
Skip to first unread message

Coulson Thabo Kgathi

unread,
Sep 13, 2012, 3:29:30 AM9/13/12
to django...@googlegroups.com
Can i be able to plot a points on maps with geodjango? i figured i can plot polygons on a map but struggling to plot points is it possible? if it is how do i do it or help with a link to information where i can find how to do that. i have been searching and cant find much infor about it.

If i can atleast plot a point like points on the map below, that would be great

HoustonCrimeMaps

Jani Tiainen

unread,
Sep 13, 2012, 3:33:10 AM9/13/12
to django...@googlegroups.com
13.9.2012 10:29, Coulson Thabo Kgathi kirjoitti:
> Can i be able to plot a points on maps with geodjango? i figured i can
> plot polygons on a map but struggling to plot points is it possible? if
> it is how do i do it or help with a link to information where i can find
> how to do that. i have been searching and cant find much infor about it.

You can.

> If i can atleast plot a point like points on the map below, that would
> be great
>
> HoustonCrimeMaps
>


How have you tried to do that exactly?

--
Jani Tiainen

- Well planned is half done and a half done has been sufficient before...

Coulson Thabo Kgathi

unread,
Sep 13, 2012, 3:51:08 AM9/13/12
to django...@googlegroups.com
What i did so far is create a GeoDjango project, the define models as shown below
#models.py looks like thi

from django.db import models

# Create your models here.
# This is an auto-generated Django model module created by ogrinspect.
from django.contrib.gis.db import models

class Locations(models.Model):
    zid = models.IntegerField()
    name = models.CharField(max_length=20)
    elev = models.FloatField()
    icon = models.IntegerField()
    point = models.PointField()                             #this i tried to do it for the poin to be ploted
    geom = models.MultiLineStringField(srid=4326)
    objects = models.GeoManager()


# Auto-generated `LayerMapping` dictionary for Locations model
locations_mapping = {
    'zid' : 'ZID',
    'name' : 'NAME',
    'elev' : 'ELEV',
    'icon' : 'ICON',
    'point' : 'POINT'
    'geom' : 'MULTILINESTRING',
}


The rest of the files i followed the GeoDjango tutorial

but this does not seem to be working, First i tred bt using a .kml file convert it to a shapefile then import it to generate models bt does not work

Jani Tiainen

unread,
Sep 13, 2012, 3:58:35 AM9/13/12
to django...@googlegroups.com
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/M2ATTXtI534J.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

How are you trying to plot your points?

Have you tried to manually insert at least one known point to be sure
that problem is not somewhere in your import process?

Coulson Thabo Kgathi

unread,
Sep 13, 2012, 4:04:31 AM9/13/12
to django...@googlegroups.com
how i plot a point atleast manually is what i cant find how to do.

If atleast i could know how, which i think is done in the models.py then i would be good to go afterwards

Jani Tiainen

unread,
Sep 13, 2012, 5:44:54 AM9/13/12
to django...@googlegroups.com
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/asb2PweS-HEJ.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.

What you really mean by "plot"?

If you mean that show it somehow somewhere on a map then there is really
nothing "built in" in Django for that. IIRC admin can show only
one (first?) geometry field defined.

So you need to have some kind of mapengine to actually produce map also
known as WMS (or WFS).

Mapserver, Mapnik or Geoserver being propably one of the most used ones.

After you have done that you can build HTML page that uses some means to
show map. OpenLayers is for that - it's javascript library to work with
(interactive) maps on a webpage.

Now you should have all pieces that allows you to put together stuff
that can show your points from a database.

Coulson Thabo Kgathi

unread,
Sep 13, 2012, 6:37:30 AM9/13/12
to django...@googlegroups.com
ok thanks let me try it now
Reply all
Reply to author
Forward
0 new messages