plot.local.moran <- function(x, variable.name, local.moran, weights, sig = 0.05, plot.only.significant = TRUE, legend.location = "bottomleft", zero.policy = NULL){ if(!inherits(local.moran, "localmoran")) stop("local.moran not an object of class localmoran") if(!inherits(weights, "listw")) stop("weight not a listw") if (!inherits(x, "SpatialPointsDataFrame") & !inherits(x, "SpatialPolygonsDataFrame")) stop("MUST be sp SpatialPointsDataFrame OR SpatialPolygonsDataFrame CLASS OBJECT")
# Check if local.moran subsetted missing data #x <- na.action(local.moran) na.act <- na.action(local.moran) # Rows to drop in weight matrix (weights) subVec <- !(1:length(weights$neighbours) %in% na.act) # Subset weights weights <- subset(weights, subVec, zero.policy = zero.policy) # Subset localmoran local.moran <- local.moran[subVec,] # Subset Polygons origPoly <- x x <- subset(x, subVec)
# Get length of x n <- length(x)
vec <- c(1:n) vec <- ifelse(local.moran[,5] < sig, 1,0) # Create the lagged variable lagvar <- lag.listw(weights, x[[variable.name]]) # get the mean of each m.myvar <- mean(x[[variable.name]]) m.lagvar <- mean(lagvar) myvar <- x[[variable.name]] # Derive quadrants q <- c(1:n) for (i in1:n){ if (myvar[[i]]>=m.myvar & lagvar[[i]]>=m.lagvar) q[i] <- 1 if (myvar[[i]]<m.myvar & lagvar[[i]]<m.lagvar) q[i] <- 2 if (myvar[[i]]<m.myvar & lagvar[[i]]>=m.lagvar) q[i] <- 3 if (myvar[[i]]>=m.myvar & lagvar[[i]]<m.lagvar) q[i] <- 4 } # set coloring scheme q.all <- q colors <- c(1:n) for (i in1:n) { if (q.all[i]==1) colors[i] <- "red" if (q.all[i]==2) colors[i] <- "blue" if (q.all[i]==3) colors[i] <- "lightblue" if (q.all[i]==4) colors[i] <- "pink" if (q.all[i]==0) colors[i] <- "white" if (q.all[i]>4) colors[i] <- "white" } # Mark all non-significant regions white locm.dt <- q*vec colors1 <- colors for (i in1:n){ if ( !(is.na (locm.dt[i])) ) {
if (locm.dt[i]==0) colors1[i] <- "grey78"
} } colors2 <- colors colors2 <- paste(colors2,vec) pos = list() for (i in1:n) { pos[[i]] <- c(which(myvar==colors2["blue 0"])) } blue0 <- which(colors2=="blue 0") red0 <- which(colors2=="red 0") lightblue0 <- which(colors2=="lightblue 0") pink0 <- which(colors2=="pink 0") lb <- 6 labels=c("High-High", "High-Low", "Low-High", "Low-Low", "Not Significant", "Missing Data") # plot the map # Plot out the full set of polygons (missing data will not be overlaid) plot(origPoly, col = "black") if (plot.only.significant == TRUE){ plot(x, col=colors1,border=T, lwd=0.2, add = TRUE) }else{ plot(x, col=colors,border=T, add = TRUE) } legend(legend.location, legend = labels, fill = c("red", "pink", "lightblue", "blue", "grey78", "black"), bty = "n") }
import matplotlib.pyplot as plt from libpysal.weights.contiguity import Queen from libpysal import examples import numpy as np import pandas as pd import geopandas as gpd import os import splot
spot_labels = [ '0 ns', '1 hot spot', '2 doughnut', '3 cold spot', '4 diamond'] labels = [spot_labels[i] for i in spots]
#这里先设置好cmap,使得之后颜色能够很好地对应 import matplotlib.cm as cm import matplotlib.colors as col colors=['#bbe0c6','#74c190','#00a15c','#17693e','#101e15'] cmap2 = col.LinearSegmentedColormap.from_list('own2',colors) # extra arguments are N=256, gamma=1.0 cm.register_cmap(cmap=cmap2)
import matplotlib.pyplot as plt import matplotlib.patches as mpatches
RUN apt-get -y install dirmngr RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 RUN apt-get update RUN apt-get -y install python3-pip #RUN apt-get -y install make #RUN apt-get -y install cmake RUN apt-get -y install libspatialindex-dev
RUN pip3 install setuptools==47.1.1 RUN pip3 install -r /root/requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple some-package RUN pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pip -U RUN pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
# (dead proxies are skipped) # otherwise EINTR is returned to the app # strict_chain # # Strict - Each connection will be done via chained proxies # all proxies chained in the order as they appear in the list # all proxies must be online to play in chain # otherwise EINTR is returned to the app # #random_chain # # Random - Each connection will be done via random proxy # (or proxy chain, see chain_len) from the list. # this option is good to test your IDS :)
# Make sense only if random_chain #chain_len = 2
# Quiet mode (no output from library) #quiet_mode
# Proxy DNS requests - no leak for DNS data proxy_dns
# Some timeouts in milliseconds tcp_read_time_out 15000 tcp_connect_time_out 8000
# ProxyList format # type host port [user pass] # (values separated by 'tab' or 'blank') # # # Examples: # # socks5 192.168.67.78 1080 lamer secret # http 192.168.89.3 8080 justu hidden # socks4 192.168.1.49 1080 # http 192.168.39.93 8080 # # # proxy types: http, socks4, socks5 # ( auth types supported: "basic"-http "user/pass"-socks ) # [ProxyList] # add proxy here ... # meanwile # defaults set to "tor" socks5 127.0.0.1 1080
requirements.txt::
1 2 3
pysal==2.1.0 jupyter==1.0.0 keplergl==0.2.0
sources.list::
1 2 3 4 5 6 7 8 9 10
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
r-tuna.list::
1
deb https://mirrors.tuna.tsinghua.edu.cn/CRAN/bin/linux/ubuntu bionic-cran40/