Skip to content
This repository has been archived by the owner on Jul 2, 2019. It is now read-only.

NULL Pointer error when trying to process a geojson file with no building footprints #85

Open
00krishna opened this issue Sep 19, 2018 · 1 comment

Comments

@00krishna
Copy link

I ran the code below to convert the Spacenet 2 Khartoum dataset to SBD format.

python2.7 createDataSpaceNet.py /path/spacenet/AOI_5_Khartoum_Train/ \
           --srcImageryDirectory RGB-PanSharpen \
           --outputDirectory /path/spacenet/AOI_5_Khartoum_Train/sbd_labels \
           --annotationType SBD \
           --convertTo8Bit \
           --outputFileType JPEG \
           --imgSizePix 650

On buildings_AOI_5_Khartoum_img3.geojson the script crashed and I got the traceback below indicating a NULL pointer.

Traceback (most recent call last):
  File "createDataSpaceNet.py", line 317, in <module>
    bboxResize= args.boundingBoxResize
  File "createDataSpaceNet.py", line 110, in processChipSummaryList
    entry = lT.geoJsonToSBD(annotationName_cls, annotationName_inst, chipSummary['geoVectorName'], chipSummary['rasterSource'])
  File "/path/spacenet_utilities/python/spaceNetUtilities/labelTools.py", line 1066, in geoJsonToSBD
    my_inst_segmentation = createInstanceSegmentation(my_raster_source, my_vector_source)
  File "/path/spacenet_utilities/python/spaceNetUtilities/labelTools.py", line 1016, in createInstanceSegmentation
    cell_array[i] = createSegmentationByFeatureIndex(i, rasterSrc, vectorSrc, npDistFileName='', units='pixels')
  File "/path/spacenet_utilities/python/spaceNetUtilities/labelTools.py", line 1004, in createSegmentationByFeatureIndex
    dist_trans_by_feature = createDistanceTransformByFeatureIndex(feature_index, rasterSrc, vectorSrc, npDistFileName='', units='pixels')
  File "/path/spacenet_utilities/python/spaceNetUtilities/labelTools.py", line 950, in createDistanceTransformByFeatureIndex
    Feature_Layer.CreateFeature(my_feature)
  File "/path/python2.7/site-packages/osgeo/ogr.py", line 1727, in CreateFeature
    return _ogr.Layer_CreateFeature(self, *args)
ValueError: Received a NULL pointer.

The error seems to be caused by the geojson file having no building footprints in it. So the script passes this empty set of footprints to OGR and OGR interprets that as a NULL. I think the solution would be to check for an empty value before passing the value to OGR.

@nrweir
Copy link
Collaborator

nrweir commented Nov 27, 2018

Related to #97

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants