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