You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is not a request for a fix. I'm just raising this issue in case it assists anyone else who has (also accidentally) tried to run sDNA using Iron Python (and maybe to provide some useful test code and an example shapefile to sdna_open).
Description: On the example shapefile attached (15x15randomGrid), sDNA Integral produces a shapefile that can be read, e.g. with QGIS, but QGIS fails to open the shapefile output from sDNA run with Iron Python. On closer inspection with PyShp 2.2, the Iron Python shapefile is of shapefile type 960051513 but the cPython one is correctly of type 13 (13 is the code for POLYLINEZ in the shapefile spec)
Instructions to reproduce:
Install Iron Python 2.7 and Python 2.7
Run test_sDNA_iron_v_cPython.py (you may need to check the directories in pythons_dict to the Python interpreters and sDNA are correct for your machine) test_sDNA.zip
The test script starts new external Python interpreter instances to run sDNA on the same shapefile in each specified Python version. Paths to the python executables to be tested should be added to pythons_dict. As hoped, the results are the same when the test script is run in any Python version (Iron Python and Python 3 have been tested and both show the same shapefile type when the output is inspected using PyShp), so reading using PyShp may not be the issue.
The text was updated successfully, but these errors were encountered:
…n del ing them.
Fixesfiftysevendegreesofrad#11
File writer objects were being relied on to close themselves.
In Iron Python relying on del to call .close()
or some other error meant Shapefile headers were
not being written properly - this should happen in the __exit__ of the
context manager but can be called in .close() if preferred. del is
known to result in wierd behaviour in cPython, and it's certainly no
better in Iron Python, so ought not be relied on to call .close()
The curious number 960051513 that made its way into the shapefile type
in the header, is 39393939 in base 16. 39 happens to be b'9'.hex(). In
shapefile.Writer.__init__ long before the header is constructed
properly (as the length of the file is not yet known) is the following line
of code:
if self.shp: self.shp.write(b'9'*100)
This just reserves the 100 bytes of space required at the start of the file
according to the ESRI shapefile spec.
This is not a request for a fix. I'm just raising this issue in case it assists anyone else who has (also accidentally) tried to run sDNA using Iron Python (and maybe to provide some useful test code and an example shapefile to sdna_open).
Description: On the example shapefile attached (15x15randomGrid), sDNA Integral produces a shapefile that can be read, e.g. with QGIS, but QGIS fails to open the shapefile output from sDNA run with Iron Python. On closer inspection with PyShp 2.2, the Iron Python shapefile is of shapefile type 960051513 but the cPython one is correctly of type 13 (13 is the code for POLYLINEZ in the shapefile spec)
Instructions to reproduce:
Install Iron Python 2.7 and Python 2.7
Run test_sDNA_iron_v_cPython.py (you may need to check the directories in pythons_dict to the Python interpreters and sDNA are correct for your machine)
test_sDNA.zip
The test script starts new external Python interpreter instances to run sDNA on the same shapefile in each specified Python version. Paths to the python executables to be tested should be added to pythons_dict. As hoped, the results are the same when the test script is run in any Python version (Iron Python and Python 3 have been tested and both show the same shapefile type when the output is inspected using PyShp), so reading using PyShp may not be the issue.
The text was updated successfully, but these errors were encountered: