Mixing CRS between assets and hazards

I have a pipeline that uses nearest neighbour sampling to find which hazard point is closest to each asset. This is working fine if the hazard and the assets are in the same CRS but does not work if they are not. I have the same assets in both EPSG:4326 and EPSG:2193 with the hazards in EPSG:4326.
Running the model using the lat/lon bookmark will produce and output where each of the assets is associated with a hazard. Running the model using the east/north bookmark produces an output where the hazard for all assets is blank.

How can I get riskscape to work when 2 different CRSs are used?

project.ini

[model nearest_neighbour]
framework = pipeline
location = nearest_neighbour.txt

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

[bookmark assets_LL]
description = point based assets in lat/lon
location = assets.csv
set-attribute.geom = create_point(Lat,Lon)
crs-name = EPSG:4326

[bookmark assets_EN]
description = point based assets in easting/northing
location = assets.csv
set-attribute.geom = create_point(x,y)
crs-name = EPSG:2193

nearest_neighbour.txt

input(bookmark('assets_LL'), 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')

hazards.csv

hazardID,Lat,Lon
5,178.5,-45.5
6,178.5,-46.5
7,178.5,-47.5
8,178.5,-48.5

assets.csv

assetID,Lat,Lon,x,y
1,178.1,-45.1,2001256.599,4993274.24
2,178.2,-45.2,2008407.537,4981663.188
3,178.3,-45.3,2015529.475,4970042.328
4,178.4,-45.4,2022622.331,4958411.678

Kia ora,

So the sampling operations should handle any difference in CRS, so in cases like this it’s not usually the pipeline but the bookmark data itself. A good tip here is to use the riskscape bookmark eval command and then open the resulting layers in QGIS (I typically visualize the data against the Open Street Map XYZ tiles layer).

So one problem looks like the Lon/Lat columns in the CSV data are mislabelled, e.g. 178.1 is the longitude for NZ, not the latitude. The assets_EN data doesn’t look right either - I think because EPSG:2193 CRS is actually y,x ordering rather than x,y (GIS is nothing if not inconsistent).

I usually refer to the EPSG website if I’m unsure about the axis ordering. The riskscape bookmark info command also displays a Axis-order in the output, based on the CRS defintion (and also potentially the bookmark config).

Hope that helps.
Tim

Hi Tim,

Thanks for that. Working well now
Cheers
John