# Creating georeferenced random data in Python/R? [closed]

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.

## closed as off-topic by PolyGeo♦Jul 9 '16 at 1:03

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – PolyGeo
If this question can be reworded to fit the rules in the help center, please edit the question.

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)
``````

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.

• 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
• Please edit your original question, as that is not explained. – Simbamangu Jul 25 '15 at 20:42

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