[mapserver-users] Calculate length!
alok mathur
mathuralok.88 at gmail.com
Mon Mar 16 01:53:37 PDT 2015
Hi Jukka,
When i am trying to run the above ogr command as mentioned by you I am
getting an error
ogrinfo -dialect sqlite -sql "select st_length(geometry) from 'Fibertech
solution'" doc_test.kml
INFO: Open of `doc_test.kml'
using driver `LIBKML' successful.
ERROR 1: In ExecuteSQL(): sqlite3_prepare(select st_length(geometry) from
'Fibertech solution'):
no such function: st_length
Please let me know what the issue is. I have installed both libsqlite3 and
libspatialite.
Thanks!
Alok
On Fri, Mar 13, 2015 at 5:04 PM, Rahkonen Jukka (MML) <
jukka.rahkonen at maanmittauslaitos.fi> wrote:
> Hi,
>
>
>
> You do not need anything else than GDAL which is compiled with libraries
> libsqlite3 and libspatialite.
>
> If you have a suitable GDAL version you should be able to repeat this with
> the attached small KML file.
>
>
>
>
>
> ogrinfo -dialect sqlite -sql "select st_length(geometry) from Layer0"
> lines.kml
>
> INFO: Open of `lines.kml'
>
> using driver `LIBKML' successful.
>
>
>
> Layer name: SELECT
>
> Geometry: None
>
> Feature Count: 2
>
> Layer SRS WKT:
>
> (unknown)
>
> st_length(geometry): Real (0.0)
>
> OGRFeature(SELECT):0
>
> st_length(geometry) (Real) = 38.2726390753108
>
>
>
> OGRFeature(SELECT):1
>
> st_length(geometry) (Real) = 34.5939953221416
>
>
>
> -Jukka Rahkonen-
>
>
>
>
>
> alok mathur wrote:
>
>
>
> Hi Rahkonen,
>
>
>
> I have a KML as data source and I am not using sqlite or postgis.
>
> I am reading the KML from ogrinfo. is there anyway to do the length
> calculation without using sqlite or postgis.
>
>
>
> Thanks!
>
> Alok
>
>
>
> On Fri, Mar 13, 2015 at 3:28 PM, Rahkonen Jukka (MML) <
> jukka.rahkonen at maanmittauslaitos.fi> wrote:
>
> Hi Lars,
>
>
>
> You should not underestimate GDAL. Read
> http://www.gdal.org/ogr_sql_sqlite.html and look at this:
>
>
>
> ogrinfo -dialect sqlite -sql "select st_length(geometry) from line_demo
> limit 5" line_demo.shp
>
> INFO: Open of `line_demo.shp'
>
> using driver `ESRI Shapefile' successful.
>
>
>
> Layer name: SELECT
>
> Geometry: None
>
> Feature Count: 10
>
> Layer SRS WKT:
>
> (unknown)
>
> st_length(geometry): Real (0.0)
>
> OGRFeature(SELECT):0
>
> st_length(geometry) (Real) = 638.237633730745
>
> OGRFeature(SELECT):1
>
> st_length(geometry) (Real) = 32.7179011265525
>
> OGRFeature(SELECT):2
>
> st_length(geometry) (Real) = 4399.43983906202
>
> OGRFeature(SELECT):3
>
> st_length(geometry) (Real) = 480.395511976145
>
> OGRFeature(SELECT):4
>
> st_length(geometry) (Real) = 311.309421824364
>
> -Jukka Rahkonen-
>
>
>
>
>
> Schylberg Lars wrote:
>
>
>
> As far as I know there is no length function in Mapserver.
>
> The only geometry function to use in Expressions is area(shape).
>
> OGR sql doesn’t provide that either as far as I can see in the
> documentation.
>
>
>
> So the solutions might be to convert your KML data to sqlite or postgis
> where such functions are available.
>
>
>
> The length of a string (number of characters in the string) can be found
> in OGR sql with the length function,
> but I am assuming You are looking for the geometric length of the
> linestring.
>
>
>
> /Lars
>
>
>
> *From:* mapserver-users-bounces at lists.osgeo.org [
> mailto:mapserver-users-bounces at lists.osgeo.org
> <mapserver-users-bounces at lists.osgeo.org>] *On Behalf Of *alok mathur
> *Sent:* den 13 mars 2015 07:01
> *To:* mapserver-users at lists.osgeo.org
> *Subject:* [mapserver-users] Calculate length!
>
>
>
> Hi,
>
>
>
> I want to calculate the length in mapserver. Is it possible. Means i have
> a linestring and i want to know the length for it.
>
> Also not could be suggest me how to do it.
>
>
>
> I am using data source to mapserver as KML.
>
>
>
> Thanks!
>
>
>
> --
>
> *Alok Mathur*
>
>
> _______________________________________________
> mapserver-users mailing list
> mapserver-users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/mapserver-users
>
>
>
>
>
> --
>
> *Alok Mathur* | Software Engineer 2A | Ciena
> Mobile +91 9899413266
>
--
*Alok Mathur* | Software Engineer 2A | Ciena
Mobile +91 9899413266
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20150316/6710ae2d/attachment.htm>
More information about the MapServer-users
mailing list