I am having trouble trying to merge two shapefiles in R. One of them has 5 polygons and the other one has 1, so I would like to obtain a final shapefile with 6 polygons.    I try to replicate the merge function from ArcGIS, unsuccessfully though. I have tried with several functions (gUnion, unión from raster package, merge), but all of them create more columns instead of adding a new row.   Could anybody help me to solve this issue?  I have tried with the methods proposed in  but they do not work in my case.
123219
I have created 2 polygons in QGIS. Using them in R, polygons become automatically SpatialPolygonsDataFrame (SPDF). I would like to merge them into single SPDF (as is super easy in ArcGis using Tool Merge). I am sure that there should be simple way how to complete that in R, but I can't find how. the merge function seems to merge only data.frames, aggregate function dissolve multiple polygons into one shp, gIntersect (by typing join function) returns logical value, not at all the SPDF.    data are available here:   library(sp) library(raster) library(rgeos) library(spatstat) library(rgdal)      library(maptools)  setwd("C:/...") a&lt;-readOGR(dsn=getwd(), layer="pol.a") b&lt;- readOGR(dsn=getwd(), layer="pol.b")  ab&lt;-merge(a, b)  # what tool if not "merge" to use??
12169
I have 100 files with 57,816 rows each.I want to do an outer join of these files by merging on basis of the common column.  I am using R programming for this but this is very slow.  fileList &lt;- list.files(, pattern=".txt") pm_list=lapply(fileList, read.table) merged_pm=merge_all(pm_list, by = "gene_short_name")   Is there any quick way to do this in bash? The other method that I can use is SQL but I have to create 100 tables first and then load them up before join,which is not very efficient way to do.  The number of rows are equal in each file, thats why I want to merge  based on common column and can't use cbind from R as the constants in the common column are a bit up and down in different files and not present at same location in each file.Below are two sample files.I want to join based on 'gene_short_name'  gene_short_name FPKM56  MT-TF   0.90 MT-TV   0 MT-RNR1 310.015 MT-TL1  0 MT-TM   0   File 2 is below:  gene_short_name FPKM53  MT-TF   0 MT-TV   0.344 MT-TM   0.10 MT-TL1  0 MT-RNR1 0 MT-ND2  158.332
72100
I am trying to intersect two SpatialPolygonsDataFrames and get a SpatialPolygonsDataFrame as the result.  Unfortunately, using the gIntersection function from rgeos (which works impressively quickly to intersect the polygons), I cannot seem to retrieve the associated dataframes.  Consider the following example:  &gt; fracPoly &lt;- gIntersection( toSingle, fromSingle ) &gt; class(toSingle) [1] "SpatialPolygonsDataFrame" &gt; class(fromSingle) [1] "SpatialPolygonsDataFrame" &gt; class(fracPoly) [1] "SpatialPolygons"   I can write a wrapper function which handles the transfer of data.frames, but it will be a minor pain to get all the checking right and before I did I was hoping someone could either confirm that there's no better way or point me towards another function (or option for gIntersection) which would allow me to retain the associated data.frames.  Update  On further reflection, this may may be very deliberate behavior by gIntersection.  After all, of the two SPDFs, whose data.frame do you pass along?  So I may have to write a wrapper which merges the two.
96601
I have a points shapefile and a polygon shapefile. I work in ArcGIS Pro. I would like to select all the polygons which have one or more points in them, however, one condition should be considered, that if one point lies in two or more polygons which overlays, only one polygon is selected. Please see picture for example. There are 3 polygons highlighted with orange circle with only one point in them. As the polygons overlay, the result I obtained from ArcGIS Summarize Within tool showed that each of these polygons consist of one point, which is wrong, cause there are not 3 points, but 1. There should be only one polygon with one point, the other one stays empty.  The result should look something like this. Orange points are selected polygons with one or more points. And pay attention to black line - these are polygons which overlays and shares a point, but only one of them are selected. Of course this could be done manually, but it's too time consuming and it gets hard when there are to many overlaying polygons, so I try to find a fast way to do this.  Here is a very similar question  about at least one and more points in polygon, but the solution selects all polygons with intersection, even if they overlay and share a common point. I couldn't find the solution with &quot;Join attributes by location&quot; or &quot;Select attributes by location&quot;. I'm probably missing something and this should be done easily. Is there some fast and effective way to do this?
105638
I have around 1,000 satellite images in tiff format, and I want to create a shapefile which will serve as an index to the rasters. This is something similar to a raster catalog, but I do not want to build a raster catalog.  Some obstacles I can forsee, is that the image are georefrenced, so they are not rectangular in shape (I am talking about the data area).  To clarify, I require the polygon to cover only the non-zero (or non nodata) pixels of the raster, and not the entire rectangular raster. Most of the answers so far, give a rectangular polygon, which covers the data, as well as the non-data pixels.  My Image     Result given by  tools I have examined (like raster catlog, various Arcscripts, custom Python script given in one of the answers):     Result that I want:
44247
I've used the integration of  with QGIS, and found it a very uesful tool. Having taken a look at the R toolbox  and the  it appears they both offer only point clustering to demonstrate the proof of concept.   Can other analysis methods available in R be implemented in ArcGIS Desktop through a python script (for example, implementing specific parts of the  package)?
46655
I'm wondering if there is any method to preserve the original field names in ArcGIS when I join csv. tables to a Shapefile.  I ask, because sometimes I  join tables with 10, 20 or even more columns and when exporting the joined data ArcGIS always renames them according to the name of the original table and the order of the column (e.g. table_xy_1,table_xy_2, etc.).  Since there is no easy way to rename the fields in the attribute table permanently (i.e. you have to create a new column and copy the old on into this new column AND delete the old column) this creates a bunch of work (despite from the fact that you have to orientate yourself in this mess of field names).
65803
I do a lot of editing, in this case areas. Sometimes I add an area to one shapefile, only to realise a bit later that it should have been in another.   Is there an easy way of copying only that polygon into the proper shapefile? Something along the lines of rightclick the row in attribute table, copy and then paste in the next attribute table.   I do know that I can select the polygon and use , but this seem unnecessary complicated?
86987
I am trying to make a new raster based on three input rasters which have the same cell size and the grids align perfectly.  I now want to construct a new raster, which for each cell, has three attributes, being the cell the values of the different input rasters. I've read about using 'combine', but this provides with an attribute table with a count of all cells with the same combination of values in the different input rasters (I hope this is clear). What I need is an attribute table in which all cells are individually represented.   Does anyone have any advice on this?
110763
I have previously asked a question on determining the area of polygons with another polygon boundary.    I came to the conculsion that using an intersect function was the most feasible option in determing the area of polygons within the 1000m boundary. Whenever I run an intersect with all the polygon shapefiles (there is about 40) within the Polygon boundary it generates an empty output.  I have set the coordinate system for each shapefile and the data frame to the same one. I'm using ArcGIS 10.1 with an ArcInfo license.  What would be the cause of this empty output generated?  WARNING 000117: warning empty output generated.
34369
I have a polyline shapefile with about 20 kinds of roads. I would like to know how can I create automatically a vector file for each one. I am aware of how to do it using ArcGIS Desktop - see  How do I do it using QGIS or SAGA?
33403
I want to do something relatively simply but it seems to be very difficult to do, though I am very new to using R for spatial data so apologies if I've missed something obvious.  I have a list containing 161 shapefiles of bird distributions in the world, they are each in the format of a SpatialPolygonsDataFrame. I also have world climate data in a raster stack format for 8 variables. Both sets of files are in the same projection (lat and long WGS84). I want to create new columns for the climate data with 1's where the species polygon overlaps with the climate data and 0 where it doesn't. I tried various functions to do this, quite a few initial options didn't work, the best option appeared to be:  pnt.in.poly(XY coordinates of climate data points, XY coordinates of species polygon)   I changed my raster of climate data into points to get the XY coordinates. I unified the polygons for each species shapefile and then used:  species@polygons[[1]]@Polygons[[1]]@cords   to get the coordinates for my species polygons as a matrix. However, I discovered that:  species@polygons[[1]]@Polygons[[1]]@coords    wasn't actually getting all the coordinates of the polygons only some of them.  I tried using fortify from the ggplot package, and it gives me a dataframe with coordinates but some of them are for holes in the polygons. I ran that with the pnt.in.poly function excluding the holes but it took an hour to run and when I looked at the output maps after it matched for some of the range but not all of it- there were holes in the distribution where there shouldn't be holes.   I also tried this method that I found somewhere else:  lonlat &lt;- lapply(slot(species, "polygons"), function(x) lapply(slot(x,"Polygons"), function(y) slot(y, "coords")))    which gives me a list with 436 items- but I'm still not sure how to get the coordinates into a matrix form that will work in pnt.in.poly.  I'm sure this should be easier to do! Does anyone know a better way?
59901
I am trying to dissolve multiple lines for stream networks into individual features. The dataset contains many stream networks so a complete dissolve of the whole dataset wont do as I would like to only dissolve streams that are in the same network (illustrated in the pictures below).  I've tried using the Unsplit Line tool and the Dissolve tool in ArcGIS 10. The tool will only join two lines together, i.e. lines that share a common end point. This is illustrated in the screenshots below.    Here is the orignal dataset with the lines split, a single line feature is highlighted    This is the same feature highlighted after using the unsplit/dissolve tool. As you can see it has only joined two lines together rather than all of the lines that are touching.  The features in the same network do not have a common attribute either.
11008
I have two point shapefiles: Red and Blue.  Each point shapefile has a z value which represents a radius (i.e. represented as buffers in the example).  A duplicate point is defined as a point that lies within Z distance of another point, which can range from 2 - 10 m.  In this example there are ten pairs of duplicate points--seven pairs overlap perfectly, while three pairs overlap by falling within another point's Z value.  I would like to keep only one of each duplicate within Z and merge the two shapefiles together in ArcGIS Desktop.    How can I find and merge duplicate points?
96226
I am trying to upload a large shapefile to ArcOnline, however I found out ArcGIS Online won't upload any shapefile that has more than 1000 features.  My 30 shapefiles have over 1,000,000 features each.    Is there a way for me to condense these files into a smaller number of features that won't require me to go through manually and break the file down into individual shapefiles of 1000 features?
121846
I am a fairly new user of QGIS having a question regarding dissolve functionality.   I am working with the  provided by EU, which I have imported in QGIS. I have created a new layer with only Denmark and Netherlands as you can see in the picture below.     The corresponding attribute table is the following.    The fields describe the ID and name for each NUTS node, as well as the country code. I have introduced a new attribute field, called Merge_attr.  I have managed to dissolve the polygons with the same attribute value of Merge_attr. However, I would like to dissolve polygons based on the Merge_attr value only when they belong to the same country and potentially only when they are adjacent.  Can we constrain dissolve functionality to only polygons that are adjacent?  This means that the following should not take place (yellow polygons got merged even though not adjacent):
52082
I wanted to join a CSV file to a shapefile.  When I identified a field to facilitate the join, e.g.,   map &lt;- spChFIDs(map, as.character(map$ID))   it returned     Error in spChFIDs(SP, x) : lengths differ   Can anyone advise?