Append/Combine Shape Files
You've got duplicated polygon IDs. You can change them manually, or use taRifx.geo:
library(devtools)
install_git("git://github.com/gsk3/taRifx.geo.git")
library(taRifx.geo)
rbind(a,b, fix.duplicated.IDs=TRUE)
Code available for inspection here.
Combining shapefiles in Python / GeoPandas
First, let's generate some data for demonstration:
import geopandas as gpd
from shapely.geometry import Point
shp1 = gpd.GeoDataFrame({'geometry': [Point(1, 1).buffer(3)], 'name': ['Shape 1']})
shp2 = gpd.GeoDataFrame({'geometry': [Point(1, 1).buffer(2)], 'name': ['Shape 2']})
shp3 = gpd.GeoDataFrame({'geometry': [Point(1, 1).buffer(1)], 'name': ['Shape 3']})
Now take the symmetric difference for all, but the smallest shape, that can be left as is:
diffs = []
gdfs = [shp1, shp2, shp3]
for idx, gdf in enumerate(gdfs):
if idx < 2:
diffs.append(gdf.symmetric_difference(gdfs[idx+1]).iloc[0])
diffs.append(shp3.iloc[0].geometry)
There you go, now you have the desired shapes as a list in diffs. If you would like to combine them to one GeoDataFrame, just do as follows:
all_shapes = gpd.GeoDataFrame(geometry=diffs)
Concat multiple shapefiles via geopandas
I can't test this since I don't have your data, but you want something like this (assuming python 3):
from pathlib import Path
import pandas
import geopandas
folder = Path("/Users/m3105/Downloads/area")
shapefiles = folder.glob("tl_2015_*_arealm.shp")
gdf = pandas.concat([
geopandas.read_file(shp)
for shp in shapefiles
]).pipe(geopandas.GeoDataFrame)
gdf.to_file(folder / 'compiled.shp')
Combine a point shapefile and a road shapefile in R
If you mean to just visualize the data then this is how you can do it. Note that your road and point shapefiles do not appear to have the same projection. Shapefiles can only hold one shape type (lines, points, polygons, etc.) so you can't really combine them.
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_geometry(pts), add = T, col = 'red', pch = 20)
Related Topics
R - Error When Using Geturl from Curl After Site Was Changed
Removing/Replacing Brackets from R String Using Gsub
How to Wrap a Function That Only Takes Individual Elements to Make It Take a List
Use Different Font Sizes for Different Portions of Text in Ggplot2 Title
Barplot with Multiple Columns in R
Loop Linear Regression and Saving Coefficients
Using Mutate Rowwise Over a Subset of Columns
Cannot Install Rgdal Package in R on Rhel6, Unable to Load Shared Object Rgdal.So
Means from a List of Data Frames in R
Do Not Open Rstudio Internal Browser After Knitting
Pipe in Magrittr Package Is Not Working for Function Load()
Cannot Install R Tseries, Quadprog ,Xts Packages in Linux
Convert Latitude/Longitude to State Plane Coordinates