Invalid geometries in buildings
Closed this issue · 2 comments
maning commented
Running the process for the whole LA County, I get this error:
time make chunks
Traceback (most recent call last):
File "chunk.py", line 73, in <module>
chunk(argv[1], argv[2], argv[3], argv[4])
File "chunk.py", line 42, in chunk
if asShape(features[j]['geometry']).intersects(sectionShape):
File "/home/penny/venvs/labuildings/local/lib/python2.7/site-packages/shapely/geometry/base.py", line 449, in intersects
return bool(self.impl['intersects'](self, other))
File "/home/penny/venvs/labuildings/local/lib/python2.7/site-packages/shapely/predicates.py", line 11, in __call__
return self.fn(this._geom, other._geom, *args)
File "/home/penny/venvs/labuildings/local/lib/python2.7/site-packages/shapely/geos.py", line 187, in errcheck_predicate
raise PredicateError("Failed to evaluate %s" % repr(func))
shapely.geos.PredicateError: Failed to evaluate <_FuncPtr object at 0x2adfc8d12870>
make: *** [chunks] Error 1
From shapely issues, this is related to invalid geometries:
Will investigate further.
maning commented
Redirecting stdout to file, I got this
Error parsing feature
{'geometry': None,
'id': '685379',
'properties': OrderedDict([(u'OBJECTID_1', 692997), (u'OBJECTID', 688434), (u'CODE', u'Building'), (u'BLD_ID', u'2014102489030000'), (u'HEIGHT', 31.2), (u'ELEV', 387.8), (u'AREA',
7057), (u'LARIAC_SOU', u'LARIAC4'), (u'LARIAC_DAT', u'2014'), (u'AIN', u'4404009001'), (u'STATUS', u'Modified'), (u'CODE_NUM', 1), (u'SOURCE', None), (u'DATE_', None), (u'Shape_Le
ng', 0.0), (u'Shape_Le_1', 0.0), (u'Shape_Area', 0.0), (u'GeneralUse', u'Residential'), (u'SpecificUs', u'Single Family Residence'), (u'YearBuilt', u'0'), (u'Specific_1', None), (u
'Units', u'0')]),
'type': 'Feature'}
Exported chunks/buildings-060373104003.shp
maning commented
To check for invalid geometries, we created this script: https://github.com/osmlab/labuildings/blob/master/utils/check_shp.py
To run:
python ../utils/check_shp.py buildings.shp > bldg_err.txt
This creates a file of invalid geometries. I removed them from the data using ogr2ogr.
ogr2ogr -overwrite buildings1.shp buildings.shp -where "(BLD_ID NOT IN ('2014073321520000','2014073494560000','480907867665','2014092885640000','2014102489030000','2014102482470000','2014113083630000','527671857199','465354755246','541839844108'))"
The chunk.py is now complete.