shapefile

in R, save a shapefile

好久不见. 提交于 2020-12-05 20:20:11
问题 I would like to save a shapefile after a manipulation. First, I read my object map<-readOGR("C:/MAPS","33SEE250GC_SIR") After this, I subset my shapefile: test <- fortify(map, region="CD_GEOCODI") test<- subset(test, -43.41<long & long < -43.1 & - 23.05<lat & lat< -22.79) I get the corresponding id's of this subset ids<- unique(test$id) map2<- map[map$CD_GEOCODI %in% ids ,] When I plot the map2, it is all right. But, when I try to save this shapefile, somethinh is wrong writeOGR(map2, dsn =

R How do I merge polygon features in a shapefile with many polygons? (reproducible code example)

好久不见. 提交于 2020-08-05 06:32:22
问题 How do I merge polygon features in a shapefile with many polygons? rbind and union just combine the rows of the shapefile features, they don't actually merge the polygons themselves. Desired result in example below: How do I get the below shapefile with duplicated ID_2 to merge to a single polygon in sptemp? Example below of GADM level 2 of Ethiopia has first two rows of the shapefile ID_2 column duplicated (value=1). I'd like sptemp with 79 features combining the first two rows that are the

Shortest distance in R

有些话、适合烂在心里 提交于 2020-07-15 09:40:47
问题 I would like to know how to calculate the shortest distance between two properties (points) for my code below. There are two shapefile files, one being a points shapefile, the other a roads shapefile. For testing, both shapefiles can be downloaded from the following website: https://github.com/JovaniSouza/JovaniSouza5/blob/master/Example.zip library(sf) roads <- st_read('Roads/Roads.shp') pts <- st_read('Points/Points.shp') %>% st_transform(crs=st_crs(roads)) plot(st_geometry(roads)) plot(st

Shortest distance in R

旧城冷巷雨未停 提交于 2020-07-15 09:38:28
问题 I would like to know how to calculate the shortest distance between two properties (points) for my code below. There are two shapefile files, one being a points shapefile, the other a roads shapefile. For testing, both shapefiles can be downloaded from the following website: https://github.com/JovaniSouza/JovaniSouza5/blob/master/Example.zip library(sf) roads <- st_read('Roads/Roads.shp') pts <- st_read('Points/Points.shp') %>% st_transform(crs=st_crs(roads)) plot(st_geometry(roads)) plot(st

Questions regarding the stplanr package in R

隐身守侯 提交于 2020-07-13 02:05:37
问题 I would like your help with the route_local function of the stplanr package (https://cran.r-project.org/web/packages/stplanr/stplanr.pdf), which is on page 89. You may realize that a map is generated from the example function, showing the path between two points (I left the code and the image generated below). I would like to do the same thing. In my case it is show the path between two points considering my roads. Both are the shapefile file. I managed to generate the roads to show (code

Questions regarding the stplanr package in R

独自空忆成欢 提交于 2020-07-13 02:04:53
问题 I would like your help with the route_local function of the stplanr package (https://cran.r-project.org/web/packages/stplanr/stplanr.pdf), which is on page 89. You may realize that a map is generated from the example function, showing the path between two points (I left the code and the image generated below). I would like to do the same thing. In my case it is show the path between two points considering my roads. Both are the shapefile file. I managed to generate the roads to show (code

Converting CSV file to shapefile - but want polygon not points

对着背影说爱祢 提交于 2020-06-27 05:35:46
问题 I have a csv dataframe with the coordinates of a square. I have converted the csv into a shapefile, but it plots as four separate points and I want the plot to show a square. Shape long lat 1 1.1 43 10 2 1.1 43 13 3 1.1 40 13 4 1.1 40 10 I have converted it into a shapefile and given it a coordinate reference system as follows: test <- as.data.frame(read_csv("/Users/alan/Desktop/Test.csv")) Coord_Ref <- st_crs(3035) plot_locations_test <- st_as_sf(test, coords = c("long", "lat"), crs =Coord