inbo / fish-tracking

🐟 Collection of scripts for processing and analysing fish tracking data
3 stars 0 forks source link

Error when trying to open shapefile containing data on the River Frome #59

Closed PieterjanVerhelst closed 3 years ago

PieterjanVerhelst commented 3 years ago

I want to calculate the distances between receivers from the River Frome, hence, I created a branch distance-frome in which I uploaded the shapefile Statutory_Main_River_Map.shp in the folder \scripts\receiver_distance_analysis\data\UK\Frome. When I run the code (line 69 - 73 in script prepare_dataset.R):

# RIVER FROME (UK)
frome <- load.shapefile("./data/UK/Frome/Statutory_Main_River_Map.shp",
                         "Statutory_Main_River_Map",
                         coordinate.string)

I get the following error:

 Error in ogrInfo(dsn = dsn, layer = layer, encoding = encoding, use_iconv = use_iconv,  : 
  Cannot open data source 
damianooldoni commented 3 years ago

Thanks @PieterjanVerhelst. I will check it next week.

PieterjanVerhelst commented 3 years ago

Just FYI: I added the file receivernetwork_frome_2014.csv in the folder \fish-tracking\scripts\receiver_distance_analysis\data containing the coordinates of the detection stations in the River Frome. Hence, when the issue is fixed to upload the frome-shapefile, running the rest of the code should result in the distance matrix between the Frome stations (obviously after setting the correct file name at line 88 in prepare_dataset.R).

PieterjanVerhelst commented 3 years ago

@damianooldoni just a kind reminder ;-)

damianooldoni commented 3 years ago

Thanks @PieterjanVerhelst, I definitely needed a reminder, especially if it is a kind one :laughing: I give a look on it immediately.

damianooldoni commented 3 years ago

.shp files are not enough to load shapes in R, you need also files with other extensions (dbf, prj, shx) which are generated together. You can see some examples in other directories, like yours here: https://github.com/inbo/fish-tracking/tree/master/scripts/receiver_distance_analysis/data/PJ_manual_water

Maybe you can consider to save your shapefiles as as geojson? See this nice INBO tutorial about it: https://inbo.github.io/tutorials/tutorials/spatial_standards_vector/#how-to-make-and-use-geojson-files-geojson geopackages are also possible (1st part of the tutorial)

PieterjanVerhelst commented 3 years ago

Thanks, that was indeed the problem!