4

I'm writing a dissertation on different parameter settings in GWR . In order to perform tests I'd need the availability of geo-referenced data that show some sort of spatial correlation (i.e. values are not independent of their geographic position but vary according to space having zones with high values as well as zones with low values). Datasets should have geographical coordinates (i.e. latitude and longitude) and their density patterns should vary. As an example: data with one/two/three centroids or with uniform distribution or data concentrated more in a corner or on the edges of the map, etc..

A good starting point for me was reading How can I conduct Geographically Weighted Principal Component Analysis using ArcGIS, Python and SPSS/R?

However I'm stuck in the process of giving these data a spatial autocorrelation.

Any idea on how to achieve this?

I seek code in either Python or R.

Arslan
  • 41
  • 3

2 Answers2

3

Here's a trivial example, which generates a single 'hotspot' around one region:

# Generate coords extent of Tanzania
x <- runif(1000, min = 30, max = 40)
y <- runif(1000, min = -12, max = -1)

# Assign some values, make data frame
xyvals <- runif(1000, min=0.1, max=0.5)
xydata <- data.frame(x, y, vals = xyvals)

# Generate a hotspot centred around Arusha
xydata$hotspot <- (xydata$x > 35.5 & xydata$x < 38.5 & xydata$y > -5 & xydata$y < -2)
xydata$vals[xydata$hotspot == T] <- xydata$vals[xydata$hotspot == T] + 1

Map it:

require(mapdata)
map("world2Hires", "Tanzania", col = 1, lty=2, lwd = 3)
points(xydata$x, xydata$y, cex = xydata$vals, col = 1 + xydata$hotspot)

enter image description here

Note that the package spatstat has a lot of better functions for this kind of thing - generating all the points correctly within the country boundaries, fox example. There is also a package hotspotr.

Simbamangu
  • 14,773
  • 6
  • 59
  • 93
  • That's absolutely great. What I need though is not an hotspot in a specific area but a varying relation changing smoothly. Sure this is a good starting point. Thank you. – Arslan Jul 25 '15 at 19:49
  • 1
    Please edit your original question, as that is not explained. – Simbamangu Jul 25 '15 at 20:42
1

In the past I've used data generated using a Gibbs Sampler which is described at http://www.geog.leeds.ac.uk/people/a.turner/publications/archive/BrunsdonEtAl1999.html

Ian Turton
  • 81,417
  • 6
  • 84
  • 185