Tag Info

Hot answers tagged

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 ...


15

Use the Erase (Analysis) Tool:


13

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

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", ...


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

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 = ...


9

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 ...


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 ...


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).


7

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 = ...


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 ...


6

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


6

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 ...


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

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 ...


6

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 ...


6

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 arcpy arcpy.env.overwriteOutput = True clip_layer = ...


5

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 ...


5

The ET GeoWizards toolset contains an Erase tool similar to the ArcGIS Erase, Erases a feature layer with the features of a polygon layer and is one of the free functions available to unregistered copies with no limitations.


5

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 ...


5

In PostGIS it's a two-stage process. First you need to find the overall length of your line geometry with ST_length() Say that produces a value of 150. Then you need to divide your desired length, 75, by the total length, giving you 0.5. Finally, with that value call ST_Line_Interpolate_Point() or ST_Line_Substring() to return the substring rather than a ...


5

A layer is composed of one or several geometries. For the intersection of layers, you must iterate through each layer geometries. With shapely it is easy, example with two shapefiles: from osgeo import ogr from shapely.wkb import loads from shapely.geometry import * # first layer, a polygon shapefile first = Polygon() # open shapefile source1 = ...


5

Yes. They are exposed in the bindings: >>> from osgeo import ogr >>> help(ogr.Layer.Intersection) Help on method Intersection in module osgeo.ogr: Intersection(self, *args, **kwargs) unbound osgeo.ogr.Layer method Intersection(self, Layer method_layer, Layer result_layer, char options = None, GDALProgressFunc callback = None, ...


5

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


5

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.


5

In ArcMap, you could use python to run nested search cursors. For example: arcpy.MakeFeatureLayer_management("region shapefile location", "Regions") arcpy.MakeFeatureLayer_management("event shapefile location", "Events") out_features = "name and location for output clips" out_count = 0 r_rows = arcpy.SearchCursor(Regions) for r_row in r_rows: r_name = ...


5

In you case (only one tool), you can simply right click on the clip tool in your toolbox, and launch it as a "batch". See the ArcGIS help for more details


5

You can place all the feature classes within a single dataset then use model builder to clip all at once and output to a new dataset:


4

As you use ArcGIS 10, i would use modelbuilder with builtin tool: Iteration Feature Selection to perform this task. See the pseudo-model in the picture. it does not need to know python scritping at all.



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