def to_topojson ( self ) : topojson = self . topojson topojson [ "objects" ] [ "points" ] = { "type" : "GeometryCollection" , "geometries" : [ point . to_topojson ( ) for point in self . points . all ( ) ] , } return json . dumps ( topojson )
geojson to topojson python
Adds points and converts to topojson string .
def to_topojson(self):
        """Adds points and converts to topojson string."""
        topojson = self.topojson
        topojson["objects"]["points"] = {
            "type": "GeometryCollection",
            "geometries": [point.to_topojson() for point in self.points.all()],
        }
        return json.dumps(topojson)