这里我想使用x和y的min和max,然后我有4个多边形点。但是如何在区域内循环?
我无法让JSON正常工作。
z.sub <- subset(z, (z$Violation.Precinct %in% police.precincts))
z.long.min <- NULL
z.long.max <- NULL
z.lat.min <- NULL
z.lat.max <- NULL
### find coordinates for each precinct
for(i in 1:length(police.precincts)){
z.long.min[i] <- min(hulls[hulls$Violation.Precinct == police.precincts[i],]$x)
z.long.max[i] <- max(hulls[hulls$Violation.Precinct == police.precincts[i],]$x)
z.lat.min[i] <- min(hulls[hulls$Violation.Precinct == police.precincts[i],]$y)
z.lat.max[i] <- max(hulls[hulls$Violation.Precinct == police.precincts[i],]$y)
}
s <- {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[z.long.min[1], z.lat.min[1]], [z.long.min[1], z.lat.max[1]], [z.long.max[1], z.lat.min[1]], [z.long.max[1], z.lat.max[1]], [z.long.min[1], z.long.max[1]]
]
]
},
"properties": {
"precinct": 1
}
}
}