[gdal-dev] Reg: Getting center coordinates for the attributes in a geojson
Even Rouault
even.rouault at spatialys.com
Wed Feb 18 03:10:11 PST 2015
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
More information about the gdal-dev
mailing list