Click on a spatialpolygons map and get details in R - r

I would like to be able to click on a specific location (cell polygon) and store details in order to investigate the relation between some of my variables.
Is it possible with shapefile?
I can not export the spatialPolygonsDataframe (dput does not work)
the spatialPolygons structure with each grid cell representing the polygons.
:

Related

How to store polygons created by addDraw in variables as sf data

How to store polygons created by addDrawToolbar in variables as sf data
By using addDrawToolbar, I was able to draw polygons on the map. Is it possible to store this polygon in a variable as sf format?
In the subsequent processing, I intend to combine (st_union) with the existing polygon (Administrative district data).
Therefore, I am looking for a way to save it as sf format data.
If you know or have a web page that you can refer to, please let me know.

How to create spatial data using shiny and leaflets

I want to create spatial data (shp data, gpkg data, geojson) using shiny and leaflet.
For example, in QGIS, I want to implement the function of Create Layer> newVectorLayer New> Shapefile Layer ... with shiny.
The geometry type I want to create is a polygon.
Therefore, I want to hit a pin on the map and create spatial data with the hit pin as the outer circumference.
Please let me know if you have a reference web page.

Extract values in a Spatial Polygon dataframe

I'm currently trying to find out a value of a certain polygon in my Spatial Polygon dataframe. I need to know what "ID" was assigned to each "FSA" level. Below is the picture of how my data is set up. The dataset is called "FSA2015EditedFINAL2". I tried this:
FSA2015EditedFINAL2#polygons[[1]]#ID
But that just tells me the first polygons ID, and I don't know what FSA that corresponds to...
I'm hoping to be able to type in the FSA I need and pull out what ID it got.
Any help would be amazing!!!!
Thanks!

Create interactive plot in R

I wonder if it is possible in R (RStudio) to have an interactive plot where user clicks in an image and this is used as input for upcoming processing. Here is my situation:
I have a raster that I plot
plot(NDVI[[4]])
[![enter image description here][1]][1]
Afterwards, I add a second layer containing polygon limits:
plot(fields, add=TRUE)
[![enter image description here][2]][2]
My objective is that user clicks on the image to select some of these polygons (let's say 3). Those clicks are used to identify those polygons which will later be used to derive the mean raster value inside the area they represent.
So far, I have been doing so updating a shapefile containing points, but I would like to make more interactive
points<-readOGR("Points_crops.shp")
fields<-readOGR("Boundaries.shp")
fields_sub <- fields[!is.na(sp::over(fields, sp::geometry(points))), ]
NDVI_mean<-lapply(NDVI, FUN=function (NDVI) {data.frame(mean=extract(NDVI,fields_sub,fun=mean))})
For those interested, I have solved the issue using the click function. This will retrieve the coordinates of the point you click with the mouse. After that, you can convert them to spatialPoints setting a proj4string (same as the one of the raster of reference).
points<-click(NDVI[[4]], n=5, xy=TRUE, show=TRUE)
points$value<-NULL
points<-SpatialPoints(points, proj4string = crs(S2_stack_crop[[2]]))
Once I have the points as spatialPoints I can continue with the next step

Tableau Map Line Graph - change linking order of data points

I have data with lat/lon attributes that I'm plotting onto a map. I then use the "line" mark to link the data points. It seems to automatically order them by the latitude attribute, which happens to bring two of my data points out of order:
How can I manually change the order of the linking?
Thanks!
There is a path shelf in Tableau, details of the usage can be found here:
http://kb.tableau.com/articles/knowledgebase/using-path-shelf-pattern-analysis
You just need to create a dimension and give each coordinate of your path a running number. Once you drop that dimension on the path shelf, Tableau will use it to determine the order of the coordinates.

Resources