[gdal-dev] Reg: Getting center coordinates for the attributes in a geojson

Manikanta Kondeti mani.iiit123 at gmail.com
Wed Feb 18 03:20:19 PST 2015


That looks pretty awesome. It is giving me a geometry object with
centroidx, centroidy.

But the issue is I lost all the 'coordinates' array in the geometry object.

So what I need is both coordinates and centroid as well.

Thanks,
Mani

On Wed, Feb 18, 2015 at 4:40 PM, Even Rouault <even.rouault at spatialys.com>
wrote:

> Le mercredi 18 février 2015 12:02:23, Manikanta Kondeti a écrit :
> > Hello,
> >
> > Thanks for the response.  Can I put a flag for the centroid computation?
> >
> > For eg:  ogr2ogr -f GeoJSON -t_srs crs:84 [name].geojson [name].shp
> >  (--flag for centroid??)
>
> If your GDAL build is configured with spatialite support (and is at least
> GDAL
> 1.10), you can try the ST_Centroid() SQL function with the SQLite dialect (
> http://www.gdal.org/ogr_sql_sqlite.html )
>
> Something like :
>
> ogr2ogr -f geojson out.json poly.shp \
>  -sql "select st_centroid(geometry) as geometry, * from poly" -dialect
> sqlite
>
> >
> >
> > On Wed, Feb 18, 2015 at 4:20 PM, Even Rouault <
> even.rouault at spatialys.com>
> >
> > wrote:
> > > Le mercredi 18 février 2015 11:43:10, Manikanta Kondeti a écrit :
> > > > Hi all,
> > > >
> > > > I'm working on a project which aims  to visualize Spatial Vector Data
> > > > on
> > >
> > > a
> > >
> > > > browser. Using gdal I will convert Shapefiles, kml, gml into geojson
> > > > and send it back to the browser.
> > > >
> > > > I want to draw labels(attributes) on the map, using GDAL can I get
> each
> > > > feature's centre coordinates without computing them on the browser
> > > > side,
> > >
> > > so
> > >
> > > > that I can easily draw them  on the map?
> > >
> > > Mani,
> > >
> > > OGR_G_Centroid() /  OGRGeometry::Centroid() should help.
> > >
> > > See
> > > http://www.gdal.org/ogr__api_8h.html#a23f5a19a81628af7f9cc59a37378cb2b
> > >
> > > Even
> > >
> > > --
> > > Spatialys - Geospatial professional services
> > > http://www.spatialys.com
>
> --
> Spatialys - Geospatial professional services
> http://www.spatialys.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20150218/c6d6e207/attachment.html>


More information about the gdal-dev mailing list