Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

what is acutally needed for pc:schemas #13

Open
ElocF opened this issue Mar 7, 2024 · 3 comments · May be fixed by #14
Open

what is acutally needed for pc:schemas #13

ElocF opened this issue Mar 7, 2024 · 3 comments · May be fixed by #14

Comments

@ElocF
Copy link

ElocF commented Mar 7, 2024

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

@gadomski
Copy link
Member

gadomski commented Mar 8, 2024

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.

@hobu
Copy link

hobu commented Mar 8, 2024

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

@ElocF
Copy link
Author

ElocF commented Mar 11, 2024

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

thank you both!

@gadomski gadomski linked a pull request Mar 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants