<div dir="ltr">That looks pretty awesome. It is giving me a geometry object with centroidx, centroidy. <div><br></div><div>But the issue is I lost all the 'coordinates' array in the geometry object.</div><div><br></div><div>So what I need is both coordinates and centroid as well.</div><div><br></div><div>Thanks, </div><div>Mani </div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 18, 2015 at 4:40 PM, Even Rouault <span dir="ltr"><<a href="mailto:even.rouault@spatialys.com" target="_blank">even.rouault@spatialys.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Le mercredi 18 février 2015 12:02:23, Manikanta Kondeti a écrit :<br>
<span class="">> Hello,<br>
><br>
> Thanks for the response.  Can I put a flag for the centroid computation?<br>
><br>
> For eg:  ogr2ogr -f GeoJSON -t_srs crs:84 [name].geojson [name].shp<br>
>  (--flag for centroid??)<br>
<br>
</span>If your GDAL build is configured with spatialite support (and is at least GDAL<br>
1.10), you can try the ST_Centroid() SQL function with the SQLite dialect (<br>
<a href="http://www.gdal.org/ogr_sql_sqlite.html" target="_blank">http://www.gdal.org/ogr_sql_sqlite.html</a> )<br>
<br>
Something like :<br>
<br>
ogr2ogr -f geojson out.json poly.shp \<br>
 -sql "select st_centroid(geometry) as geometry, * from poly" -dialect sqlite<br>
<div class="HOEnZb"><div class="h5"><br>
><br>
><br>
> On Wed, Feb 18, 2015 at 4:20 PM, Even Rouault <<a href="mailto:even.rouault@spatialys.com">even.rouault@spatialys.com</a>><br>
><br>
> wrote:<br>
> > Le mercredi 18 février 2015 11:43:10, Manikanta Kondeti a écrit :<br>
> > > Hi all,<br>
> > ><br>
> > > I'm working on a project which aims  to visualize Spatial Vector Data<br>
> > > on<br>
> ><br>
> > a<br>
> ><br>
> > > browser. Using gdal I will convert Shapefiles, kml, gml into geojson<br>
> > > and send it back to the browser.<br>
> > ><br>
> > > I want to draw labels(attributes) on the map, using GDAL can I get each<br>
> > > feature's centre coordinates without computing them on the browser<br>
> > > side,<br>
> ><br>
> > so<br>
> ><br>
> > > that I can easily draw them  on the map?<br>
> ><br>
> > Mani,<br>
> ><br>
> > OGR_G_Centroid() /  OGRGeometry::Centroid() should help.<br>
> ><br>
> > See<br>
> > <a href="http://www.gdal.org/ogr__api_8h.html#a23f5a19a81628af7f9cc59a37378cb2b" target="_blank">http://www.gdal.org/ogr__api_8h.html#a23f5a19a81628af7f9cc59a37378cb2b</a><br>
> ><br>
> > Even<br>
> ><br>
> > --<br>
> > Spatialys - Geospatial professional services<br>
> > <a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a><br>
<br>
--<br>
Spatialys - Geospatial professional services<br>
<a href="http://www.spatialys.com" target="_blank">http://www.spatialys.com</a><br>
</div></div></blockquote></div><br></div>