Tag Info

Hot answers tagged

18

Use the Erase (Analysis) Tool:


15

You need to loop through your inputs. Multivalue is semicolon delimited. Split on that and loop through them. (AddMessages to show how the fcs are presented) import arcpy ins = arcpy.GetParameterAsText(0) arcpy.AddMessage(ins) for fc in ins.split(';'): arcpy.AddMessage(fc) arcpy.Clip_analysis(fc, clipfeats, out) Though I'm not entirely sure of ...


14

I would drop using the maps package and find a state shapefile. Then load that into R using rgdal, and then do some polygon overlay work. library(raster) # use state bounds from gadm website: # us = shapefile("USA_adm1.shp") us <- getData("GADM", country="USA", level=1) # extract states (need to uppercase everything) nestates <- c("Maine", "Vermont", ...


14

Here is an approach using extract() from the raster package. I tested it with altitude and mean temperature data from the WorldClim website (I limit this example to altitude, temperature works similar), and an appropriate shapefile of the US containing state borders is to be found here. Just download the .zip data and decompress it to your working directory. ...


12

After trying around with everything I finally figured out how to solve the problem. It had indeed to do with the CRS. Right click "Set CRS" was not enough here. I had to perform (on the raster) Raster->Projections->Warp, then set the desired CRS again and save as Geotiff. The mask layer (vector layer) had to be saved again with the same CRS. After that the ...


11

The following script clips polygon watersheds to polygon county boundaries, naming each output featureclass something like HspWBD_HU12_county name. Tested and it works. Make sure your values in the NAME field have no special characters or spaces (simple Python string methods can clean that up for you). import arcpy arcpy.env.workspace = ...


11

Dont use env.extent you need to get raster extent. import arcpy elevRaster = arcpy.sa.Raster('C:/data/elevation') myExtent = elevRaster.extent print myExtent i hope it helps you...


9

You can use the dataset extent as a polygon geometry with the clip tool, as in the Using geometries in geoprocessing tools example. import arcpy pnt_array = arcpy.Array() extent = arcpy.Raster(in_raster).extent pnt_array.add(extent.lowerLeft) pnt_array.add(extent.lowerRight) pnt_array.add(extent.upperRight) pnt_array.add(extent.upperLeft) poly = ...


9

One of your layers (the coastline) is a polyline layer. You are probably trying to clip with it and the tool would not work. However, it looks like your coastline forms a closed shape and probably could be converted to a polygon feature class if you really want to clip with it. Feature To Polygon tool might help to convert it. EDIT (thanks to Paul): One ...


9

ModelBuilder functions differently than batch processing in ArcGIS. Typically, you use iterators to loop through individual files rather than a spreadsheet-type list of files and actions, as in batch mode. The following is an example of the type of model you would need to loop through a workspace containing rasters in order to clip them to study area ...


8

You can use the Erase Tool in ArcToolBox. According to ESRI website : "The Erase tool is used to perform overlay analysis on feature classes. This tool creates a feature class from those features or portions of features outside the erase feature class." Have a look at this webpage, they have really nice explanations. To do an "Erase" using a Basic level ...


8

If you want a solution that does not involve any extra extensions or "high-grade" licences you can try this: Union A1 and A2 to make A3. Then select by location where A3 does not have its center in A2 (you may need to select A3 where it DOES have its centre in A2 and then switch selection). OR select by attributes as Union will append attributes from A1 ...


8

From this blog post: Geo-Processing in QGIS Given the two input shapes below: Clip creates a new shape based on the area of the input layer that is overlapped by the clipping layer. It is similar to the intersection but differs in that the attributes of the chosen layer only are copied to the new feature. It is similar to MapInfo’s Erase Outside ...


8

Since Erase (as @Jens linked) only is available with an Advanced license, you can download ET Geowizards. It can be installed as an Arcmap toolbox. Although you have to pay for the full suite, there's a free part of the program and the Erase function is included there (Overlay group).


8

I ran a test to determine how the speed and quality differs between the two methods, here are the results: Input data 4-band NAIP DOQQ image in .img format (349.34MB) A feature class used as the mask/clipper Performance Three trials were performed and benchmarked. The Clip (Data Management) method is significantly faster than the Extract by Mask ...


8

Seems to be a simple application of gDifference from the rgeos package: > require(rgeos) > ukhole = gDifference(uk, lnd) Warning message: In RGEOSBinTopoFunc(spgeom1, spgeom2, byid, id, "rgeos_difference") : spgeom1 and spgeom2 have different proj4 strings > plot(ukhole) The projection warning is because the LondonBoroughs shapefile doesn't ...


8

If you change your program to read the file name from the command line and split up your input file in smaller chunks, you can do something like this using GNU Parallel: parallel my_processing.py {} /path/to/polygon_file.shp ::: input_files*.shp This will run 1 job per core. All new computers have multiple cores, but most programs are serial in nature ...


7

you can use ogr2ogr if you want: ogr2ogr -clipsrc polygonforclipping.shp out.shp in.shp * * * -clipsrc [xmin ymin xmax ymax]|WKT|datasource|spat_extent: (starting with GDAL 1.7.0) clip geometries to the specified bounding box (expressed in source SRS), WKT geometry (POLYGON or MULTIPOLYGON), from a datasource or to the spatial extent of the ...


7

In qgis 1.8 you can use Vector->Geoprocessing-Tools -> clip: Select Input vector (ex: AUT in screenshot ) clipping-polygon-Layer (ex: clipper in screenshot) and save clipped layer to disk (ex: GEclipt). Attenion: copy prj file from input-file over clipped-layer-file, because this prj-file is empty. After this you can use / add it ... Of course you can ...


7

You can use a simple block of code either directly from Python window in ArcGIS or as a Python script or as a custom script tool. Below is a sample code for a script tool. Just add your vector layers into a map document (.mxd) and specify the clip layer and the output geodatabase. import os, arcpy arcpy.env.overwriteOutput = True clip_layer = ...


6

It seems a SRS problem. What's the coordinate reference system of your project? Your x coordinates seem wrong. Best regards


6

A lot depends on how your data are stored. If your data store has grown organically and the data are jumbled in a load of directories and mix of shapefiles and geodatabases, you could use the Python os.walk function to list your directory structure and then subset your list to include only GDBs and SHPs. You would then need to recursively work through each ...


6

There is no clip analysis tool available within the default application, however you can create your own clip geoprocessing service and use that within ArcGIS Explorer. See the following links below: Using geoprocessing services in ArcGIS Explorer for Windows Desktop Geoprocessing service example: Clip And Ship


6

You are correct about needing to convert the layer name to a string. You can get the layer name as a string by calling lyr.name. The reason for this is each layer is a layer object, which won't work in os.path.join(). However, the object has a 'name' property that you can set or pass to other string functions. To use it, call ...


6

Sure You can get the function from the processing toolbox. Here's how to use it: As per http://qgis.org/de/docs/user_manual/processing/console.html From the console you can get a list of all the algorithms available which contain the word "clip" by typing: import processing processing.alglist("clip") Then you could find out how to use what appears the ...


6

The main difference will be in the attributes of the results. When using Clip only the input feature’s attributes will be in the output (none from the clip feature), where if you used Intersect the attributes form all features used will be in the output.


6

What you want to do is not a clip, a clip operation would mean you are removing geometry from a layer using another layer as the clipping boundary. You want to do a Join. To do it in ArcGIS, which I assume you're using because you mention modelbuilder: Add the shapefile to your project. Right-click the layer's name, click Joins and Relates > Join... Choose ...


6

There is a QGIS plugin called Digitizing Tools: The documentation says: Split selected features with selected line(s) from another layer applies to: line and polygon layer (multi or single part) Splits all selected features of the active layer with the selected line features of another layer. The splitting creates new features (not multi features). Each ...


6

It's not a very well-known feature, but you need the Feature Type Connections window. You access it like this (View > Windows > Feature Type Connections): In there select all the source feature types, select the transformer point to connect to, then click Connect:


5

Here's what I used to do a quick count of GIS data on a server. Should be easy to modify for the intersect. import arcpy from arcpy import env import os env.workspace = "G:/data" fcList = [] count = 0 for dirname, dirnames, filenames in os.walk('G:/data'): for subdirname in dirnames: print os.path.join(dirname, subdirname) env.workspace ...



Only top voted, non community-wiki answers of a minimum length are eligible