Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am doing a project for a telecom company. I have to render circles on the map(assuming the center of the circle as tower and circle as the area covered by that signal), I am using base layers as Google Maps,Yahoo maps(Spherical Mercator) So I have used CreateGeodesicPolygon() successfully to create circles by reading the values from DB.

Now Since I have to render lot of circles, it made me switch to geoserver. Since the data is being provided by telecom company , they provide Lat,Lon,Gt,Gr,Pt,Pr,lambda(I think their meaning is irrelevant here) values. These values are stored in the database as they are. Now should use a equation(FRIIS transmission equation) and substitute each row(of a tower) values to find the distance covered by the tower.Then I have to create circles with that distance(considered as radius) and lon/lat and render them on map using geoserver.

Please suggest me any ideas of how to carry on this task.... I wud be thankful to your guidance

My Idea is to use these steps once I get distance from the equation.Will this work???

CREATE TABLE circles (cid int4,point_circle st_geometry);

INSERT INTO circles 
        ST_BUFFER(ST_GeomFromText('POINT(lon lat)',SRID),radius,'quad-segs=8')

Create a POSTGIS store in geoserver and this circles table as a layer.

share|improve this question
Can you create views in the database? Is it a PostGIS db? –  underdark Jun 1 '11 at 20:22
@underdark, Yes it is a postgisdb, But I never created any views –  Vikash Talanki Jun 1 '11 at 21:04
You'll have to reproject your data before buffering. (You don't get real circles if you buffer using degrees.) Then it should work. –  underdark Jun 1 '11 at 21:54
@underdark, SRID: 4326 gives buffers in metres. But since I am using google maps as base layers whose projection is 900913, where should I transform the buffer projection, in JS or SQL query itself?? –  Vikash Talanki Jun 2 '11 at 6:33
add comment

3 Answers

up vote 2 down vote accepted

Using EPSG:4326 you'll buffer in degrees, EPSG:900913 will let you buffer in meters. Google Mercator doesn't lead to correct length measurements but if you just want to get an approximate feel for your data, you should be fine.

This will create a view containing the circles in Google Mercator projection:

   ) AS tower_circle
FROM towers;
share|improve this answer
the equation I am to use for calculating radius is radius=(lambda/4*pi)*sqrt((Pt*Gt*Gr)/Pr)..... My towers table contains the following columns tid,lat,lon,lambda,Pt,Gt,Gr,Pr.... so can I use the query CREATE VIEW circles AS SELECT tower_id, ST_BUFFER( ST_Transform( ST_SetSRID( ST_MakePoint(lon,lat), 4326), 900913, (lambda/4*pi)*sqrt((Pt*Gt*Gr)/Pr) ) AS tower_circle FROM towers; –  Vikash Talanki Jun 2 '11 at 10:40
looks good to me –  underdark Jun 2 '11 at 10:50
add comment

Have a look at this blog post http://geo-solutions.blogspot.com/2010/11/fun-stuff-computing-circular-buffers-in.html that discusses using the WPS service in GeoServer to produce circles. It also shows why what you are trying to do will probably not produce the results you expect for largish distances.

share|improve this answer
Wont this work: insert point,radius values in postgis table using ST_Buffer() and just add this postgis table to geoserver, ofcourse the prerequisite is to calculate the radius(distance) from the equation –  Vikash Talanki Jun 1 '11 at 21:12
add comment

You can do it with JavaScript if you'd like and have the client browser take care of it: You can test the code on this website: http://jsfiddle.net/NtuEv/

Basically the function takes a 3 arguments: latitude, longitude and radius. It will return the coordinates that make up the circle.

You can play with the following line of code to output the coordinates however you like either in linestring fashion or whatever:

response += lon_rad.toDeg() + "," + lat_rad.toDeg() + ",0 ";

Javascript Code:

var divElement = $('div#info');

// extend Number object with methods for converting degrees/radians
/** Convert numeric degrees to radians */
if (typeof (String.prototype.toRad) === "undefined") {
    Number.prototype.toRad = function () {
        return this * Math.PI / 180;

/** Convert radians to numeric (signed) degrees */
if (typeof (String.prototype.toDeg) === "undefined") {
    Number.prototype.toDeg = function () {
        return this * 180 / Math.PI;

function fmod (X, Y) {
 return X % Y;

function GetCircleCoordinates (lat, lng, radius) {

        var response = "";
        var rLat = lat.toRad();
        var rLon = lng.toRad();

        var d_rad = radius / 6378137;

        for (i = 0; i <= 360; i++) {

            var radial = i.toRad();
            var lat_rad = Math.asin(Math.sin(rLat) * Math.cos(d_rad) + Math.cos(rLat) * Math.sin(d_rad) * Math.cos(radial));
            var dlon_rad = Math.atan2(Math.sin(radial) * Math.sin(d_rad) * Math.cos(rLat), Math.cos(d_rad) - Math.sin(rLat) * Math.sin(lat_rad));
            var lon_rad = fmod((rLon + dlon_rad + Math.PI), 2 * Math.PI) - Math.PI;
            response += lon_rad.toDeg() + "," + lat_rad.toDeg() + ",0 ";

        return response;

var circlecoords = GetCircleCoordinates(22.26, -73.34, 1100);


EDIT #1: Updated jsfiddle link.... it was wrong, it is: http://jsfiddle.net/NtuEv/

share|improve this answer
I have many circles to render, using javascript I think I cannot do for more than 50. This is why I switched to geoserver. Am I right? –  Vikash Talanki Jun 2 '11 at 18:18
That's correct, i wouldn't use the JS then. I'll leave the answer up in case someone else needs a javascript to make circles. –  CaptDragon Jun 2 '11 at 18:53
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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