2016-06-29 4 views
0

다른 카운티 조합에서 나온 다각형.순서를 변경하는 방법 정식 클래스 공간 다각형 나는 (텍사스에 한함) 미국 인구 조사 자료를 사용하여 33을 만들려는거야</p> <p>를 사용하여 공식 클래스 공간 다각형의 집합을 재정렬 할 수있는 방법을 찾고 있어요

library(tmap) 
library(maptools) 
library(ggplot2) 
library(rgeos) 
library(sp) 
library(mapdata) 
library(rgdal) 
library(raster) 

# Download the map of texas and get the LMAs boundaries 
# Download shape 
f <- tempfile() 
download.file("http://www2.census.gov/geo/tiger/GENZ2010/gz_2010_us_050_00_20m.zip", destfile = f) 
unzip(f, exdir = ".") 
US <- read_shape("gz_2010_us_050_00_20m.shp") 

# Select only Texas 
Texas <- US[(US$STATE %in% c("48")),] 


# Load the LMA append data 
LMAs = read.table('LMA append data.csv',header=T, sep=',') 

# Append LMA data to Texas shape 
Texas$FIPS <- paste0(Texas$STATE, Texas$COUNTY) 
Texas <- append_data(Texas, LMAs, key.shp = "FIPS", key.data = "FIPS") 
Texas <- Texas[order(Texas$LMA),] 

# Create shape object with LMAs polygons 
Texas_LMA <- unionSpatialPolygons(Texas, IDs=Texas$LMA) 

나는

# Create shape object with LMAs polygons 
Texas_LMA <- unionSpatialPolygons(Texas, IDs=Texas$LMA) 
spp <- SpatialPolygonsDataFrame(Texas_LMA,data=matrix(1:33,nrow=33,ncol=1)) 

와 SpatialPolygonsDataFrame에 Texas_LMA 변환 시도했다 그러나 그것은 나를 위해 일하지 않았다.

답변

0

귀하의 질문은 명확하지 않습니다. 그러나 나는이 생각하는 당신은 후에 무엇을 : 당신은 너무 여기에서 약간의 추측은 LMA 데이터를 제공하지 않았다

library(raster) 
f <- tempfile() download.file("http://www2.census.gov/geo/tiger/GENZ2010/gz_2010_us_050_00_20m.zip", destfile = f) 
unzip(f, exdir = ".") 
US <- shapefile("gz_2010_us_050_00_20m.shp") 
Texas <- US[(US$STATE %in% c("48")),] 
LMAs = read.csv('LMA append data.csv') 
Texas$FIPS <- paste0(Texas$STATE, Texas$COUNTY) 

하십시오 SpatialPolygonDataFrame로를 얻을 수

Texas <- merge(Texas, LMAs, by="FIPS") 
Texas_LMA <- aggregate(Texas, by='LMA') 
+0

을하고 그것은 나를 재 수 필요한 순서대로 다각형을 정렬하십시오. 도와 주셔서 감사합니다! – rskinner593