Problems found with expression 'create_point()'

I am trying to create a point based on an XY value but I am getting the error that the XY columns are unable to be found. The columns are shown in the error message to be part of the file it is just unable to detect them for some reason.

C:\Users\powellj\>riskscape model run addSSPIds
[WARNING] A Java upgrade is recommended. Your computer is currently using Java version 11.0.19, which will no longer be supported by future versions of RiskScape (RiskScape v1.5.0 onwards). Please upgrade to Java 17 (or higher) to ensure RiskScape will continue to run on your computer.
[WARNING] The 'beta' plugin is enabled. This contains experimental features that may significantly change or be deprecated in future releases.
Failed to validate model for execution
  - Failed to validate 'input(bookmark('assets'), name: 'assets')' step for execution
    - Parameter 'relation' requires value, but expression 'bookmark('assets')' cannot be realized
      - Problems found with 'bookmark' riskscape function
        - Problems found with 'assets' bookmark in location file:///C:/Users/powellj/AAL_High_lat_lon.csv
          - Could not apply all `set-attribute` parameters
            - Problems found with attribute geom
              - Problems found with expression 'create_point(exposedBuildings.Y_Coord, exposedBuildings.X_Coord)'
                - Could not find 'exposedBuildings.Y_Coord' among [exposedBuildings.fid, exposedBuildings.building_i, exposedBuildings.X_Coord, exposedBuildings.Y_Coord]
                - Could not find 'exposedBuildings.X_Coord' among [exposedBuildings.fid, exposedBuildings.building_i, exposedBuildings.X_Coord, exposedBuildings.Y_Coord]

project.ini

[model addSSPIds]
description = Adds ssp IDs to the output of addBuildingLocations
framework = pipeline
location = addSSPIds.txt

[bookmark hazard_points]
description = point based hazard
location = SSPSiteIds.csv
set-attribute.geom = create_point(lat,lon)
crs-name = EPSG:4326

[bookmark assets]
description = point based assets
location = AAL_High_lat_lon.csv
set-attribute.geom = create_point(exposedBuildings.Y_Coord,exposedBuildings.X_Coord)
crs-name = EPSG:2193

addSSPIds.txt

input(bookmark('assets'), name: 'assets')
->
select({
		*,
		to_coverage(bookmark('hazard_points'), options: {index:'nearest_neighbour', nearest_neighbour_max_distance: 100000}) as hazard_coverage
		})
->
select({
		*,
		sample_centroid(assets.geom, hazard_coverage) as hazard_coverage
		})
->
select({
		assets,
		hazard_coverage
		})
->
save('output.csv', format: 'csv')

AAL_High_lat_lon.csv

exposedBuildings.fid,exposedBuildings.building_i,exposedBuildings.X_Coord,exposedBuildings.Y_Coord
1,1,1574914,5184025

SSPSiteIDs.csv

siteId,lat,lon
689,-36.6197,174.6772

When you read in a CSV column that contains a ‘.’ in the name, you need to use double-quotes to escape the . operator. So your bookmark line probably needs to be:

`set-attribute.geom = create_point("exposedBuildings.Y_Coord","exposedBuildings.X_Coord")

Otherwise it tries to treat exposedBuildings as a struct, rather than part of the column name.

We could probably write structs to CSV using ‘_’ instead of ‘.’, which would make the outputs a bit easier to load back into RiskScape.

thanks Tim. Frustrating that

set-attribute.geom = create_point(lat,lon)

works but

set-attribute.geom = create_point(exposedBuildings.Y_Coord,exposedBuildings.X_Coord)

does not.

Is there any situation where wrapping a column name in double quotes does not work? I might just do that from now on.

No, always using double-quotes should be fine. E.g.

set-attribute.geom = create_point("lat", "lon")

It should pretty much always work with set-attribute, but in an expression outside of your bookmark you should only use double quotes if you’ve ended up with dots in your property names. Like Tim says, we probably shouldn’t be writing out dots in CSVs, as it only ends it tears.