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


10

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


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

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


8

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


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

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


7

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


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

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

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


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

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

Try the following: Run an Intersect on your two polygon layers Run a custom script tool called Split Layer by Attributes I had a similar question a while back and had great success with the advice given to me.


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

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


4

Rasters to the rescue! You can do this operation by converting your shapefile to a raster, doing the 'invert' operation and convert it back to vector Raster -> Convert -> Rasterize. Output layer raster1 Open field calculator, enter expression raster1@1 = 0 Raster -> Convert -> Polygonize, Output layer ocean_polygons Open Attribute table, search for DN = ...


4

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.


4

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


4

You can take boundaries properly into account when calculating kernels using the R package 'adehabitatHR' - see this link: http://cran.r-project.org/web/packages/adehabitatHR/vignettes/adehabitatHR.pdf You have to use a relatively simple boundary line and have no locations that are erroneously on the wrong side of it. This is the only proper ...


4

Using ArcGIS, there are two general methods for subsetting a shapefile. If you have features within your counties .shp (e.g. administrative voting areas, census zones etc), simply select those feature and export them as a new shapefile (Figure 1). The second method involves clipping a subset of your county .shp based on a polygon. You can accomplish this ...


4

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


4

Almost any time you use cursors to manipulate geodatabase rows one by one, you should expect a slower process than if you can find a way to do the same thing but on larger selections. Compare the difference of, say, iterating through a point feature class containing 5000 points with a search cursor and buffering each one individually then merging the ...


4

Other ideas you could try: gdal_translate with the -srcwin switch gdalwarp with -cutline and -crop_to_cutline and -wm switches. The last one specifies memory for caching and may get you over the issues you had using clipper in QGIS (as this is essentially the same function) QGIS raster calculator setting the extent to the area you want (simpler than ...


4

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


4

It should not matter whether it is uses a geographic or projected coordinate system. The only way of finding out would be to look at the metadata. It may or may not have come with metadata. If it is a shapefile, you will have to right click on the title of the field at the top of the table and click on calculate geometry to update the values. If it is a ...


3

In QGIS, use the Clipper raster tool, under the Raster-> Extraction menu. See: How to clip a raster with vector boundaries? You may have issues trying to clip data in a plugin layer (e.g. Openlayers) because the Clipper function requires a input graphic file (raster) from disk. Your best bet is to get the satellite imagery directly from the source and ...



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