So i have the shapefile with all the geodata that i need
so far my code i have tried is this
tm_shape(LSOA_London) + tm_fill( "$Crime_rate", palette = "spectral") + tm_border()
the issue i am having is that the "crime_rate" data is from a csv file and i dont know how to convert it so that it will work in my map.
do i need to rasterise the data?
any help would be great!
as shown above that is what i have tried, im yet to merge the csv with the .shp file but again im unsure on how this works. i havent done rstudio coding for a while so its all very rusty.
You have to join the shape data with the data in
.csvfile. As it's hard to guess the data you are using, below example based on some online data available. The join type depends on kind of the data in two datasets: either you can useleft_join()from {dplyr} package to join on particular columns, eitherleft_join()from {sf} package, if both datasets are spatial data.The boundaries came from {geographr} package:
And crime data from online resource:
As you can see, both datasets have a 'common' column
lsoa11_codein boundaries andLSOA.Codein crime data. We can use this column to join both datasets, filter out just example column with numbers of crime and summarise it for each LSOA area:Created on 2024-03-04 with reprex v2.1.0