Location estimation methods based on multiple surfaces?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Location estimation methods based on multiple surfaces?

Andy Bunn-4
Hello all. I’m probably reinventing the wheel here and wonder if somebody can point me in a better direction.

I have about 10 surfaces of signal strength (z) received at a transmitter. Here I’ll provide an example with four surfaces `r1`, `r2`, `r3`, `r4`.

    library(raster)
    library(gstat)
    set.seed(3178)
    n <- 100
    r0 <- raster(nrows=n, ncols=n,xmn=1, xmx=n,ymn=1,ymx=n)
    r0 <- as(r0,"SpatialGrid")
    pts <- data.frame(x=c(10,20,60,80,1,1,n,n),y=c(10,80,70,40,1,n,1,n),
                      id=c(1:4,rep(0,4)), z=c(c(rep(1,4)),rep(0,4)))

    pts <- SpatialPointsDataFrame(pts[,1:2],data=pts[,3:4])


    r1 <- idw(z~1,pts[c(1,5:8),],newdata=r0)
    r2 <- idw(z~1,pts[c(2,5:8),],newdata=r0)
    r3 <- idw(z~1,pts[c(3,5:8),],newdata=r0)
    r4 <- idw(z~1,pts[c(4,5:8),],newdata=r0)

    r1 <- raster(r1)
    r2 <- raster(r2)
    r3 <- raster(r3)
    r4 <- raster(r4)

I also have a series of points with signal strengths that correspond to each surface. The locations of these points is unknown. The task is to determine a location for each point. E.g., for `unknownXY`:

    # Extract a point. For the real data I would have the z data but not x and y
    cell2get <- floor(runif(1,1,n^2))
    unknownXY <- c(extract(brick(r1,r2,r3,r4),cell2get))

In this case there is a four-way intersection of the contour lines that I could find suing some kind of intersection technique (e.g., `rgeos::gIntersection`).


    # Here is the the contour for the unknown point on each raster
    plot(r1,axes=F)
    contour(r1,levels=unknownXY[1],add=TRUE)

    plot(r2,axes=F)
    contour(r2,levels=unknownXY[2],add=TRUE)

    plot(r3,axes=F)
    contour(r3,levels=unknownXY[3],add=TRUE)

    plot(r4,axes=F)
    contour(r4,levels=unknownXY[4],add=TRUE)

    # here are all 4 contours
    plot(r0,axes=F,col="white")
    contour(r1,levels=unknownXY[1],add=TRUE,drawlabels=FALSE,col="red")
    contour(r2,levels=unknownXY[2],add=TRUE,drawlabels=FALSE,col="blue")
    contour(r3,levels=unknownXY[3],add=TRUE,drawlabels=FALSE,col="purple")
    contour(r4,levels=unknownXY[4],add=TRUE,drawlabels=FALSE,col="green")

But there are times when, I think, that there will not be a completely pure intersection (e.g., the contours will not exactly overlap). In that case I’m wondering about using a probabilistic method for finding x,y for a given vector of z.

One thing I was thinking was calculating distances. E.g.,

    # calc distances
    r1d <- sqrt((unknownXY[1] - r1)^2)
    r2d <- sqrt((unknownXY[2] - r2)^2)
    r3d <- sqrt((unknownXY[3] - r3)^2)
    r4d <- sqrt((unknownXY[4] - r4)^2)
    plot(brick(r1d,r2d,r3d,r4d))

And them summing them:

    # Straight sum? Should they be weighted in some manner?
    rdSum <- sum(brick(r1d,r2d,r3d,r4d))
    plot(rdSum)

I could find the min value to get the ``best'' point:

    # Use min to get possible location. Seems easy to get trapped.
    rdSumMin <- rdSum == minValue(rdSum)
    plot(rdSumMin)

Or use a threshold value to get a series of locations that are the most likely:

    # Or use quantile to get possible locations?
    thresh <- quantile(rdSum, probs = c(0.01))
    rdSum99 <- rdSum < thresh
    plot(rdSum99)

What I’m wondering it whether there is a way of finding a surface that is explicitly probabilistic. What I’d like to do is be able to determine possible location with x% likelihood.

Any ideas, tips, tricks, appreciated.











        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Reply | Threaded
Open this post in threaded view
|

Re: Location estimation methods based on multiple surfaces?

Andy Bunn-4
Excellent. I think I have a way forward worked out in my head. But as with many things, I need to go back and think about what it is I’m really after as the end product. I might be heading down the wrong path. Thanks for your help.

From: Barry Rowlingson <[hidden email]>
Date: Friday, June 28, 2019 at 4:12 AM
To: Andy Bunn <[hidden email]>
Cc: R-sig-Geo <[hidden email]>
Subject: Re: [R-sig-Geo] Location estimation methods based on multiple surfaces?

This has also been posted to gis.stackexchange.com<https://nam03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fgis.stackexchange.com&data=02%7C01%7Cbunna%40wwu.edu%7C1cf95b53c5474c35586d08d6fbb97375%7Cdc46140ce26f43efb0ae00f257f478ff%7C0%7C1%7C636973171266761575&sdata=lAXBPTNLIUZvpmJCx8FzCwZ7%2FeCu%2F6hi%2BbtK7OSZfGY%3D&reserved=0> where I've blathered a bit about probability distributions:

https://gis.stackexchange.com/questions/327164/location-estimation-methods-based-on-multiple-surfaces/327174#327174<https://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgis.stackexchange.com%2Fquestions%2F327164%2Flocation-estimation-methods-based-on-multiple-surfaces%2F327174%23327174&data=02%7C01%7Cbunna%40wwu.edu%7C1cf95b53c5474c35586d08d6fbb97375%7Cdc46140ce26f43efb0ae00f257f478ff%7C0%7C1%7C636973171266761575&sdata=WOdNOrWftOgPl2%2BWzDQRokTOkek8mn4UgpmdtvOulBE%3D&reserved=0>

That site might not be the best place to solve the problem if it gets a bit too much like a discussion - the question might be a bit broad...

Barry


On Thu, Jun 27, 2019 at 10:00 PM Andy Bunn <[hidden email]<mailto:[hidden email]>> wrote:
Hello all. I’m probably reinventing the wheel here and wonder if somebody can point me in a better direction.

I have about 10 surfaces of signal strength (z) received at a transmitter. Here I’ll provide an example with four surfaces `r1`, `r2`, `r3`, `r4`.

    library(raster)
    library(gstat)
    set.seed(3178)
    n <- 100
    r0 <- raster(nrows=n, ncols=n,xmn=1, xmx=n,ymn=1,ymx=n)
    r0 <- as(r0,"SpatialGrid")
    pts <- data.frame(x=c(10,20,60,80,1,1,n,n),y=c(10,80,70,40,1,n,1,n),
                      id=c(1:4,rep(0,4)), z=c(c(rep(1,4)),rep(0,4)))

    pts <- SpatialPointsDataFrame(pts[,1:2],data=pts[,3:4])


    r1 <- idw(z~1,pts[c(1,5:8),],newdata=r0)
    r2 <- idw(z~1,pts[c(2,5:8),],newdata=r0)
    r3 <- idw(z~1,pts[c(3,5:8),],newdata=r0)
    r4 <- idw(z~1,pts[c(4,5:8),],newdata=r0)

    r1 <- raster(r1)
    r2 <- raster(r2)
    r3 <- raster(r3)
    r4 <- raster(r4)

I also have a series of points with signal strengths that correspond to each surface. The locations of these points is unknown. The task is to determine a location for each point. E.g., for `unknownXY`:

    # Extract a point. For the real data I would have the z data but not x and y
    cell2get <- floor(runif(1,1,n^2))
    unknownXY <- c(extract(brick(r1,r2,r3,r4),cell2get))

In this case there is a four-way intersection of the contour lines that I could find suing some kind of intersection technique (e.g., `rgeos::gIntersection`).


    # Here is the the contour for the unknown point on each raster
    plot(r1,axes=F)
    contour(r1,levels=unknownXY[1],add=TRUE)

    plot(r2,axes=F)
    contour(r2,levels=unknownXY[2],add=TRUE)

    plot(r3,axes=F)
    contour(r3,levels=unknownXY[3],add=TRUE)

    plot(r4,axes=F)
    contour(r4,levels=unknownXY[4],add=TRUE)

    # here are all 4 contours
    plot(r0,axes=F,col="white")
    contour(r1,levels=unknownXY[1],add=TRUE,drawlabels=FALSE,col="red")
    contour(r2,levels=unknownXY[2],add=TRUE,drawlabels=FALSE,col="blue")
    contour(r3,levels=unknownXY[3],add=TRUE,drawlabels=FALSE,col="purple")
    contour(r4,levels=unknownXY[4],add=TRUE,drawlabels=FALSE,col="green")

But there are times when, I think, that there will not be a completely pure intersection (e.g., the contours will not exactly overlap). In that case I’m wondering about using a probabilistic method for finding x,y for a given vector of z.

One thing I was thinking was calculating distances. E.g.,

    # calc distances
    r1d <- sqrt((unknownXY[1] - r1)^2)
    r2d <- sqrt((unknownXY[2] - r2)^2)
    r3d <- sqrt((unknownXY[3] - r3)^2)
    r4d <- sqrt((unknownXY[4] - r4)^2)
    plot(brick(r1d,r2d,r3d,r4d))

And them summing them:

    # Straight sum? Should they be weighted in some manner?
    rdSum <- sum(brick(r1d,r2d,r3d,r4d))
    plot(rdSum)

I could find the min value to get the ``best'' point:

    # Use min to get possible location. Seems easy to get trapped.
    rdSumMin <- rdSum == minValue(rdSum)
    plot(rdSumMin)

Or use a threshold value to get a series of locations that are the most likely:

    # Or use quantile to get possible locations?
    thresh <- quantile(rdSum, probs = c(0.01))
    rdSum99 <- rdSum < thresh
    plot(rdSum99)

What I’m wondering it whether there is a way of finding a surface that is explicitly probabilistic. What I’d like to do is be able to determine possible location with x% likelihood.

Any ideas, tips, tricks, appreciated.











        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]<mailto:[hidden email]>
https://stat.ethz.ch/mailman/listinfo/r-sig-geo<https://nam03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fstat.ethz.ch%2Fmailman%2Flistinfo%2Fr-sig-geo&data=02%7C01%7Cbunna%40wwu.edu%7C1cf95b53c5474c35586d08d6fbb97375%7Cdc46140ce26f43efb0ae00f257f478ff%7C0%7C1%7C636973171266771583&sdata=mtkWNtpKSRkRLfgU2SjO%2Blo7wSpIhH1d61iZSILPRxA%3D&reserved=0>

        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
[hidden email]
https://stat.ethz.ch/mailman/listinfo/r-sig-geo