I have been trying to use the GEOS linear referencing functions through
the base geometry class as Sean suggested in an earlier email, and
although interpolation works, projection does not (lgeos.GEOSProject
gives a return code of 0 instead of 1). Do you have any idea why this
is happening?
from shapely.geometry import base, LineString
from shapely.geos import lgeos
line = LineString([[0, 0], [2, 0]])
print '==== Interpolation ===='
point = base.geom_factory(lgeos.GEOSInterpolateNormalized(line._geom,
base.c_double(0.5)))
print point.wkt
print '==== Projection ===='
scalar = base.c_double()
returnCode = lgeos.GEOSProject(point._geom, line._geom, base.byref(scalar))
if returnCode == 1:
print 'Projection of %s onto %s is %s' % (point.wkt, line.wkt,
scalar.value)
else:
print 'Projection failed'
--
Roy Hyunjin Han
http://invisibleroads.com
We train people to become software developers and connect them to jobs
and projects for local businesses
from shapely.geometry import base, LineString
from shapely.geos import lgeos
line = LineString([[0, 0], [2, 0]])
print '==== Interpolation ===='
point = base.geom_factory(lgeos.GEOSInterpolateNormalized(line._geom,
base.c_double(0.5)))
print point.wkt
print '==== Projection ===='
scalar = base.c_double()
returnCode = lgeos.GEOSProject(point._geom, line._geom, base.byref(scalar))
if returnCode == 1:
print 'Projection of %s onto %s is %s' % (point.wkt, line.wkt, scalar.value)
else:
print 'Projection failed'
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community