I want to plot a figure with my data combined to an shapefile. However, at the moment I am not able to receive output yet since the data from the shapefile covers a larger area than my dataset. My shapefile covers the whole Netherlands (postal codes 1011: 9999) and my dataset only a small part (postal codes 2651: 3344).
In other words, I need to cut my shapefile to ensure both areas have overlap. Doing so I will have no NA's and I can get output. I have read several posts, including this one: How to cut a shape ile?
However, it is still not clear for me how to handle this. Should I use
ogr2ogr within R and can I best code this? The explanation on http://www.gdal.org/ogr2ogr.html is quite difficult to follow.
I selected only for the relevant postalcodes, via the comments of Spacedman and Isaac Freitas (both worked). After this I wanted to plot the data using the following code:
However, I still get the same error message as before:
Error in gray(studyArea$data$sumBeperking/max(studyArea$data$sumBeperking)) :
invalid gray level, must be in [0,1].
What would cause this even though the data is correct now?