Discussion:
[Community] exception thrown in parallel_offset
Alex Flint
2014-04-28 18:55:30 UTC
Permalink
The following code produces an exception under shapely (python version)
1.3.0

import shapely.geometry
path = shapely.geometry.LineString([
[581037.19575668662, 4509299.98342364],
[580996.61134201661, 4509304.202782942],
[581037.19575668662, 4509299.98342364],
[581072.19594137045, 4509296.7024005251],
[581072.19594137045, 4509296.7024005251],
[581037.19575668662, 4509299.98342364]
])
path.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)

The exception is:

File
"/Users/alexflint/Code/wifi-localization/tools/localization/estimation/scripts/shapely_bug.py",
line 39, in <module>
linestring.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/linestring.py",
line 114, in parallel_offset
bool(side == 'left')))
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/base.py",
line 55, in geom_factory
raise ValueError("No Shapely geometry can be created from null value")
ValueError: No Shapely geometry can be created from null value

The points on the path above are actually very close to collinear, but my
understanding was that parallel_offset should work regardless. I have
attached a plot of the path itself.

Any suggestions for what's going on here?

Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140428/874e7d72/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: path.pdf
Type: application/pdf
Size: 8176 bytes
Desc: not available
URL: <http://lists.gispython.org/pipermail/community/attachments/20140428/874e7d72/attachment.pdf>
Oleksandr Huziy
2014-04-28 19:12:21 UTC
Permalink
I get this error message when executing your code:

ERROR:shapely.geos:TopologyException: depth mismatch at at
581037.39250326285 4509301.9737485535


Have no idea what this means, but maybe you know))

Cheers
Post by Alex Flint
The following code produces an exception under shapely (python version)
1.3.0
import shapely.geometry
path = shapely.geometry.LineString([
[581037.19575668662, 4509299.98342364],
[580996.61134201661, 4509304.202782942],
[581037.19575668662, 4509299.98342364],
[581072.19594137045, 4509296.7024005251],
[581072.19594137045, 4509296.7024005251],
[581037.19575668662, 4509299.98342364]
])
path.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/Users/alexflint/Code/wifi-localization/tools/localization/estimation/scripts/shapely_bug.py",
line 39, in <module>
linestring.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/linestring.py",
line 114, in parallel_offset
bool(side == 'left')))
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/base.py",
line 55, in geom_factory
raise ValueError("No Shapely geometry can be created from null value")
ValueError: No Shapely geometry can be created from null value
The points on the path above are actually very close to collinear, but my
understanding was that parallel_offset should work regardless. I have
attached a plot of the path itself.
Any suggestions for what's going on here?
Alex
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140428/b0d91990/attachment.htm>
Alex Flint
2014-04-28 19:23:53 UTC
Permalink
Hmm that's strange, I haven't seen that error. What version of shapely are
you using (I'm using 1.3.0). Also I'm on python 1.7.6.

Attaching the exact python script that I am running at my end.

I have also found that if I add small random numbers to each element of the
data array (gaussian random numbers of order 1e-2) then I do not get the
crash (and in fact I get the correct result), which suggests to me that
this is some instability/round-off issue.

Alex
ERROR:shapely.geos:TopologyException: depth mismatch at at 581037.39250326285 4509301.9737485535
Have no idea what this means, but maybe you know))
Cheers
Post by Alex Flint
The following code produces an exception under shapely (python version)
1.3.0
import shapely.geometry
path = shapely.geometry.LineString([
[581037.19575668662, 4509299.98342364],
[580996.61134201661, 4509304.202782942],
[581037.19575668662, 4509299.98342364],
[581072.19594137045, 4509296.7024005251],
[581072.19594137045, 4509296.7024005251],
[581037.19575668662, 4509299.98342364]
])
path.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/Users/alexflint/Code/wifi-localization/tools/localization/estimation/scripts/shapely_bug.py",
line 39, in <module>
linestring.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/linestring.py",
line 114, in parallel_offset
bool(side == 'left')))
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/base.py",
line 55, in geom_factory
raise ValueError("No Shapely geometry can be created from null value")
ValueError: No Shapely geometry can be created from null value
The points on the path above are actually very close to collinear, but my
understanding was that parallel_offset should work regardless. I have
attached a plot of the path itself.
Any suggestions for what's going on here?
Alex
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140428/d5e0d6f9/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: aa.py
Type: text/x-python-script
Size: 422 bytes
Desc: not available
URL: <http://lists.gispython.org/pipermail/community/attachments/20140428/d5e0d6f9/attachment-0001.bin>
Alex Flint
2014-04-28 19:24:12 UTC
Permalink
Sorry, python 2.7.6.
Post by Alex Flint
Hmm that's strange, I haven't seen that error. What version of shapely are
you using (I'm using 1.3.0). Also I'm on python 1.7.6.
Attaching the exact python script that I am running at my end.
I have also found that if I add small random numbers to each element of
the data array (gaussian random numbers of order 1e-2) then I do not get
the crash (and in fact I get the correct result), which suggests to me that
this is some instability/round-off issue.
Alex
ERROR:shapely.geos:TopologyException: depth mismatch at at 581037.39250326285 4509301.9737485535
Have no idea what this means, but maybe you know))
Cheers
Post by Alex Flint
The following code produces an exception under shapely (python version)
1.3.0
import shapely.geometry
path = shapely.geometry.LineString([
[581037.19575668662, 4509299.98342364],
[580996.61134201661, 4509304.202782942],
[581037.19575668662, 4509299.98342364],
[581072.19594137045, 4509296.7024005251],
[581072.19594137045, 4509296.7024005251],
[581037.19575668662, 4509299.98342364]
])
path.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/Users/alexflint/Code/wifi-localization/tools/localization/estimation/scripts/shapely_bug.py",
line 39, in <module>
linestring.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/linestring.py",
line 114, in parallel_offset
bool(side == 'left')))
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/base.py",
line 55, in geom_factory
raise ValueError("No Shapely geometry can be created from null value")
ValueError: No Shapely geometry can be created from null value
The points on the path above are actually very close to collinear, but
my understanding was that parallel_offset should work regardless. I have
attached a plot of the path itself.
Any suggestions for what's going on here?
Alex
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140428/4bea38da/attachment.htm>
Oleksandr Huziy
2014-04-28 19:31:13 UTC
Permalink
I am using Python 2.7.6 and shapely 1.3.1.

What I also noticed that if you increase the distance to 10000 the error
also disappears...

Cheers
Post by Alex Flint
Sorry, python 2.7.6.
Post by Alex Flint
Hmm that's strange, I haven't seen that error. What version of shapely
are you using (I'm using 1.3.0). Also I'm on python 1.7.6.
Attaching the exact python script that I am running at my end.
I have also found that if I add small random numbers to each element of
the data array (gaussian random numbers of order 1e-2) then I do not get
the crash (and in fact I get the correct result), which suggests to me that
this is some instability/round-off issue.
Alex
ERROR:shapely.geos:TopologyException: depth mismatch at at 581037.39250326285 4509301.9737485535
Have no idea what this means, but maybe you know))
Cheers
Post by Alex Flint
The following code produces an exception under shapely (python version)
1.3.0
import shapely.geometry
path = shapely.geometry.LineString([
[581037.19575668662, 4509299.98342364],
[580996.61134201661, 4509304.202782942],
[581037.19575668662, 4509299.98342364],
[581072.19594137045, 4509296.7024005251],
[581072.19594137045, 4509296.7024005251],
[581037.19575668662, 4509299.98342364]
])
path.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/Users/alexflint/Code/wifi-localization/tools/localization/estimation/scripts/shapely_bug.py",
line 39, in <module>
linestring.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/linestring.py",
line 114, in parallel_offset
bool(side == 'left')))
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/base.py",
line 55, in geom_factory
raise ValueError("No Shapely geometry can be created from null value")
ValueError: No Shapely geometry can be created from null value
The points on the path above are actually very close to collinear, but
my understanding was that parallel_offset should work regardless. I have
attached a plot of the path itself.
Any suggestions for what's going on here?
Alex
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140428/5f923d21/attachment.htm>
Oleksandr Huziy
2014-04-28 19:44:40 UTC
Permalink
I have to mention that I am running your script using ipython notebook,
apparently it gives better exception information.

Here is the notebook with the full exception.

http://nbviewer.ipython.org/urls/raw.githubusercontent.com/guziy/PyNotebooks/master/shapely_test.ipynb?create=1

Cheers
Post by Oleksandr Huziy
I am using Python 2.7.6 and shapely 1.3.1.
What I also noticed that if you increase the distance to 10000 the error
also disappears...
Cheers
Sorry, python 2.7.6.
Post by Alex Flint
Post by Alex Flint
Hmm that's strange, I haven't seen that error. What version of shapely
are you using (I'm using 1.3.0). Also I'm on python 1.7.6.
Attaching the exact python script that I am running at my end.
I have also found that if I add small random numbers to each element of
the data array (gaussian random numbers of order 1e-2) then I do not get
the crash (and in fact I get the correct result), which suggests to me that
this is some instability/round-off issue.
Alex
ERROR:shapely.geos:TopologyException: depth mismatch at at 581037.39250326285 4509301.9737485535
Have no idea what this means, but maybe you know))
Cheers
Post by Alex Flint
The following code produces an exception under shapely (python
version) 1.3.0
import shapely.geometry
path = shapely.geometry.LineString([
[581037.19575668662, 4509299.98342364],
[580996.61134201661, 4509304.202782942],
[581037.19575668662, 4509299.98342364],
[581072.19594137045, 4509296.7024005251],
[581072.19594137045, 4509296.7024005251],
[581037.19575668662, 4509299.98342364]
])
path.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/Users/alexflint/Code/wifi-localization/tools/localization/estimation/scripts/shapely_bug.py",
line 39, in <module>
linestring.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/linestring.py",
line 114, in parallel_offset
bool(side == 'left')))
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/base.py",
line 55, in geom_factory
raise ValueError("No Shapely geometry can be created from null value")
ValueError: No Shapely geometry can be created from null value
The points on the path above are actually very close to collinear, but
my understanding was that parallel_offset should work regardless. I have
attached a plot of the path itself.
Any suggestions for what's going on here?
Alex
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
--
Sasha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140428/a97b136a/attachment-0001.htm>
Alex Flint
2014-04-28 19:47:13 UTC
Permalink
Ah, this seems to be a bug in shapely -- WindowsError is not defined except
on windows. I patched line 115 of linestring.py replacing "WindowsError"
with "OSError". (This is literally the only patch I've applied to my
shapely install.)
Post by Oleksandr Huziy
I have to mention that I am running your script using ipython notebook,
apparently it gives better exception information.
Here is the notebook with the full exception.
http://nbviewer.ipython.org/urls/raw.githubusercontent.com/guziy/PyNotebooks/master/shapely_test.ipynb?create=1
Cheers
I am using Python 2.7.6 and shapely 1.3.1.
Post by Oleksandr Huziy
What I also noticed that if you increase the distance to 10000 the error
also disappears...
Cheers
Sorry, python 2.7.6.
Post by Alex Flint
Post by Alex Flint
Hmm that's strange, I haven't seen that error. What version of shapely
are you using (I'm using 1.3.0). Also I'm on python 1.7.6.
Attaching the exact python script that I am running at my end.
I have also found that if I add small random numbers to each element of
the data array (gaussian random numbers of order 1e-2) then I do not get
the crash (and in fact I get the correct result), which suggests to me that
this is some instability/round-off issue.
Alex
On Mon, Apr 28, 2014 at 3:12 PM, Oleksandr Huziy <guziy.sasha at gmail.com
ERROR:shapely.geos:TopologyException: depth mismatch at at 581037.39250326285 4509301.9737485535
Have no idea what this means, but maybe you know))
Cheers
Post by Alex Flint
The following code produces an exception under shapely (python
version) 1.3.0
import shapely.geometry
path = shapely.geometry.LineString([
[581037.19575668662, 4509299.98342364],
[580996.61134201661, 4509304.202782942],
[581037.19575668662, 4509299.98342364],
[581072.19594137045, 4509296.7024005251],
[581072.19594137045, 4509296.7024005251],
[581037.19575668662, 4509299.98342364]
])
path.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/Users/alexflint/Code/wifi-localization/tools/localization/estimation/scripts/shapely_bug.py",
line 39, in <module>
linestring.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/linestring.py",
line 114, in parallel_offset
bool(side == 'left')))
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/base.py",
line 55, in geom_factory
raise ValueError("No Shapely geometry can be created from null value")
ValueError: No Shapely geometry can be created from null value
The points on the path above are actually very close to collinear,
but my understanding was that parallel_offset should work regardless. I
have attached a plot of the path itself.
Any suggestions for what's going on here?
Alex
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
--
Sasha
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140428/9549fb00/attachment.htm>
Sean Gillies
2014-04-28 20:59:29 UTC
Permalink
Thanks for the report, debugging, and support! I've got the fix here at
https://github.com/Toblerity/Shapely/issues/128.
Post by Alex Flint
Ah, this seems to be a bug in shapely -- WindowsError is not defined
except on windows. I patched line 115 of linestring.py replacing
"WindowsError" with "OSError". (This is literally the only patch I've
applied to my shapely install.)
Post by Oleksandr Huziy
I have to mention that I am running your script using ipython notebook,
apparently it gives better exception information.
Here is the notebook with the full exception.
http://nbviewer.ipython.org/urls/raw.githubusercontent.com/guziy/PyNotebooks/master/shapely_test.ipynb?create=1
Cheers
I am using Python 2.7.6 and shapely 1.3.1.
Post by Oleksandr Huziy
What I also noticed that if you increase the distance to 10000 the error
also disappears...
Cheers
Sorry, python 2.7.6.
Post by Alex Flint
Post by Alex Flint
Hmm that's strange, I haven't seen that error. What version of shapely
are you using (I'm using 1.3.0). Also I'm on python 1.7.6.
Attaching the exact python script that I am running at my end.
I have also found that if I add small random numbers to each element
of the data array (gaussian random numbers of order 1e-2) then I do not get
the crash (and in fact I get the correct result), which suggests to me that
this is some instability/round-off issue.
Alex
On Mon, Apr 28, 2014 at 3:12 PM, Oleksandr Huziy <
ERROR:shapely.geos:TopologyException: depth mismatch at at 581037.39250326285 4509301.9737485535
Have no idea what this means, but maybe you know))
Cheers
Post by Alex Flint
The following code produces an exception under shapely (python
version) 1.3.0
import shapely.geometry
path = shapely.geometry.LineString([
[581037.19575668662, 4509299.98342364],
[580996.61134201661, 4509304.202782942],
[581037.19575668662, 4509299.98342364],
[581072.19594137045, 4509296.7024005251],
[581072.19594137045, 4509296.7024005251],
[581037.19575668662, 4509299.98342364]
])
path.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/Users/alexflint/Code/wifi-localization/tools/localization/estimation/scripts/shapely_bug.py",
line 39, in <module>
linestring.parallel_offset(2,
shapely.geometry.JOIN_STYLE.mitre)
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/linestring.py",
line 114, in parallel_offset
bool(side == 'left')))
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/base.py",
line 55, in geom_factory
raise ValueError("No Shapely geometry can be created from null value")
ValueError: No Shapely geometry can be created from null value
The points on the path above are actually very close to collinear,
but my understanding was that parallel_offset should work regardless. I
have attached a plot of the path itself.
Any suggestions for what's going on here?
Alex
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
--
Sasha
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sean Gillies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140428/22fb0362/attachment-0001.htm>
Oleksandr Huziy
2014-04-28 21:19:12 UTC
Permalink
Hi Sean:

But do you think the TopologyException for this input is a correct behavior
? If yes do you know why it happens and what is the meaning of depth in the
message:

ERROR:shapely.geos:TopologyException: depth mismatch at at
581037.39250326285 4509301.9737485535
Post by Sean Gillies
Thanks for the report, debugging, and support! I've got the fix here at
https://github.com/Toblerity/Shapely/issues/128.
Post by Alex Flint
Ah, this seems to be a bug in shapely -- WindowsError is not defined
except on windows. I patched line 115 of linestring.py replacing
"WindowsError" with "OSError". (This is literally the only patch I've
applied to my shapely install.)
Post by Oleksandr Huziy
I have to mention that I am running your script using ipython notebook,
apparently it gives better exception information.
Here is the notebook with the full exception.
http://nbviewer.ipython.org/urls/raw.githubusercontent.com/guziy/PyNotebooks/master/shapely_test.ipynb?create=1
Cheers
I am using Python 2.7.6 and shapely 1.3.1.
Post by Oleksandr Huziy
What I also noticed that if you increase the distance to 10000 the
error also disappears...
Cheers
Sorry, python 2.7.6.
Post by Alex Flint
Post by Alex Flint
Hmm that's strange, I haven't seen that error. What version of
shapely are you using (I'm using 1.3.0). Also I'm on python 1.7.6.
Attaching the exact python script that I am running at my end.
I have also found that if I add small random numbers to each element
of the data array (gaussian random numbers of order 1e-2) then I do not get
the crash (and in fact I get the correct result), which suggests to me that
this is some instability/round-off issue.
Alex
On Mon, Apr 28, 2014 at 3:12 PM, Oleksandr Huziy <
ERROR:shapely.geos:TopologyException: depth mismatch at at 581037.39250326285 4509301.9737485535
Have no idea what this means, but maybe you know))
Cheers
Post by Alex Flint
The following code produces an exception under shapely (python
version) 1.3.0
import shapely.geometry
path = shapely.geometry.LineString([
[581037.19575668662, 4509299.98342364],
[580996.61134201661, 4509304.202782942],
[581037.19575668662, 4509299.98342364],
[581072.19594137045, 4509296.7024005251],
[581072.19594137045, 4509296.7024005251],
[581037.19575668662, 4509299.98342364]
])
path.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/Users/alexflint/Code/wifi-localization/tools/localization/estimation/scripts/shapely_bug.py",
line 39, in <module>
linestring.parallel_offset(2,
shapely.geometry.JOIN_STYLE.mitre)
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/linestring.py",
line 114, in parallel_offset
bool(side == 'left')))
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/base.py",
line 55, in geom_factory
raise ValueError("No Shapely geometry can be created from null value")
ValueError: No Shapely geometry can be created from null value
The points on the path above are actually very close to collinear,
but my understanding was that parallel_offset should work regardless. I
have attached a plot of the path itself.
Any suggestions for what's going on here?
Alex
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
--
Sasha
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sean Gillies
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140428/bd24918f/attachment.htm>
Alex Flint
2014-04-28 21:34:16 UTC
Permalink
Thanks for the quick turn-around Sean, but unfortunately this does not fix
the problem.

Before applying your fix I do indeed get "global name 'WindowsError' not
defined". Applying your change does fix this issue, but in its place I get
another error. The error I get after applying your fix is (copied from
above):

File
"/Users/alexflint/Code/wifi-localization/tools/localization/estimation/scripts/shapely_bug.py",
line 39, in <module>
linestring.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/linestring.py",
line 114, in parallel_offset
bool(side == 'left')))
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/base.py",
line 55, in geom_factory
raise ValueError("No Shapely geometry can be created from null value")
ValueError: No Shapely geometry can be created from null value

Alex
Post by Sean Gillies
Thanks for the report, debugging, and support! I've got the fix here at
https://github.com/Toblerity/Shapely/issues/128.
Post by Alex Flint
Ah, this seems to be a bug in shapely -- WindowsError is not defined
except on windows. I patched line 115 of linestring.py replacing
"WindowsError" with "OSError". (This is literally the only patch I've
applied to my shapely install.)
Post by Oleksandr Huziy
I have to mention that I am running your script using ipython notebook,
apparently it gives better exception information.
Here is the notebook with the full exception.
http://nbviewer.ipython.org/urls/raw.githubusercontent.com/guziy/PyNotebooks/master/shapely_test.ipynb?create=1
Cheers
I am using Python 2.7.6 and shapely 1.3.1.
Post by Oleksandr Huziy
What I also noticed that if you increase the distance to 10000 the
error also disappears...
Cheers
Sorry, python 2.7.6.
Post by Alex Flint
Post by Alex Flint
Hmm that's strange, I haven't seen that error. What version of
shapely are you using (I'm using 1.3.0). Also I'm on python 1.7.6.
Attaching the exact python script that I am running at my end.
I have also found that if I add small random numbers to each element
of the data array (gaussian random numbers of order 1e-2) then I do not get
the crash (and in fact I get the correct result), which suggests to me that
this is some instability/round-off issue.
Alex
On Mon, Apr 28, 2014 at 3:12 PM, Oleksandr Huziy <
ERROR:shapely.geos:TopologyException: depth mismatch at at 581037.39250326285 4509301.9737485535
Have no idea what this means, but maybe you know))
Cheers
Post by Alex Flint
The following code produces an exception under shapely (python
version) 1.3.0
import shapely.geometry
path = shapely.geometry.LineString([
[581037.19575668662, 4509299.98342364],
[580996.61134201661, 4509304.202782942],
[581037.19575668662, 4509299.98342364],
[581072.19594137045, 4509296.7024005251],
[581072.19594137045, 4509296.7024005251],
[581037.19575668662, 4509299.98342364]
])
path.parallel_offset(2, shapely.geometry.JOIN_STYLE.mitre)
File
"/Users/alexflint/Code/wifi-localization/tools/localization/estimation/scripts/shapely_bug.py",
line 39, in <module>
linestring.parallel_offset(2,
shapely.geometry.JOIN_STYLE.mitre)
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/linestring.py",
line 114, in parallel_offset
bool(side == 'left')))
File
"/usr/local/Cellar/python/2.7.6/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/shapely/geometry/base.py",
line 55, in geom_factory
raise ValueError("No Shapely geometry can be created from null value")
ValueError: No Shapely geometry can be created from null value
The points on the path above are actually very close to collinear,
but my understanding was that parallel_offset should work regardless. I
have attached a plot of the path itself.
Any suggestions for what's going on here?
Alex
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sasha
--
Sasha
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
--
Sean Gillies
_______________________________________________
Community mailing list
Community at lists.gispython.org
http://lists.gispython.org/mailman/listinfo/community
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gispython.org/pipermail/community/attachments/20140428/a428ccca/attachment-0001.htm>
Loading...