stac-extensions/pointcloud

what is acutally needed for pc:schemas

ElocF opened this issue · 3 comments

Hi, I am trying to utilize the point Cloud extension but am running into issues with the required schemas.

I used the pdal to STAC .py(https://github.com/stac-extensions/pointcloud/blob/main/examples/pdal-to-stac.py) script to create a JSON, the call to apply the schema to the point cloud extension returns the error: dict object has not attribute to_dict

the portion of the json schema looks like this:

 "pc:schemas": [
      {
        "name": "X",
        "size": 8,
        "type": "floating"
      },
      {
        "name": "Y",
        "size": 8,
        "type": "floating"
      },
      {
        "name": "Z",
        "size": 8,
        "type": "floating"
      },
      {
        "name": "Intensity",
        "size": 2,
        "type": "unsigned"
      }] 

The full json can be found here: https://github.com/ElocF/BC_Webmap_Lidar_STAC/blob/main/src/bc_092o018_3_2_4_xyes_12_utm10_2018.json

The call to assign the json section of the schema looks like this:

 for id, laz_info in laz_dict.items():
    for key in laz_info:
        # print(id)
        # print(key)
        # print(laz_info[key])
        laz_uri=key
        print(f"Processing {laz_uri}")
        #read json for corresponding laz file from s3
        laz_json=s3_client.get_object(Bucket=test_bucket, Key=laz_info[key])
        json_text = laz_json["Body"].read().decode()
        json_content= json.loads(json_text)

        # Extract bbox coordinates
        bbox_coords = json_content['bbox']
        left, bottom, right, top = bbox_coords[0], bbox_coords[1], bbox_coords[3], bbox_coords[4]   
        # Create bounding box
        bbox = [left, bottom, right, top]
        footprint = Polygon([(left, bottom), (right, bottom), (right, top), (left, top), (left, bottom)])
        footprint=mapping(footprint)
        
        point_count=(json_content['properties']['pc:count'])
        point_density=(json_content['properties']["pc:density"])
        point_schemas=(json_content['properties']["pc:schemas"])   # need to fix schema some how https://pystac.readthedocs.io/en/latest/api/extensions/pointcloud.html#pystac.extensions.pointcloud.Schema
        point_type=(json_content['properties']["pc:type"])
        point_stats=(json_content['properties']["pc:statistics"])
        point_epsg=(json_content['properties']["pc:epsg"])
        
        print(point_schemas)
        
        item=pystac.Item(
            id=f"laz{id}", 
            geometry=footprint,
            bbox=bbox,
            datetime=datetime.utcnow(),
            properties={},
        )
        item.validate
        
        #look to see if any of the common_metadata would be good for us
        # maybe license?
        #https://pystac.readthedocs.io/en/latest/api/common_metadata.html
        # item.common_metadata.gsd = 0.3
        # item.common_metadata.platform = "Maxar"
        # item.common_metadata.instruments = ["WorldView3"]
        item.common_metadata.object=key 
        
        
        #set point cloud extension
        pc_ext = PointcloudExtension.ext(item,  add_if_missing=True).apply(
            count= point_count,
            type= point_type,
            encoding= "binary",                                   # not sure what to put for this??????
            schemas= point_schemas,
            density= point_density,
            statistics=point_stats #,
            #epsg= point_epsg
        ) 

The full script we are working on is located here: https://github.com/ElocF/BC_Webmap_Lidar_STAC/blob/main/src/STAC/Create_STAC.ipynb

what am I missing in regards to the schema??

Thanks

There's some discussion in #3, but in short they're not super-useful, so we've made schemas optional. We've merged those changes to main, but haven't released them yet. We probably should.

I agree that we should roll the new version of the extension that makes the schemas optional.

Any ETA for the new release? alternatively is there any documentation on how the schemas should look?

thank you both!