1
vote
1answer
15 views

Intersect shapefile with raster, then determine proportion of each raster value?

Using the arcpy module in Python, I want to find the proportion of each pixel value within the boundary of an overlaying polygon. (The polygon is in a shapefile.) For example, there are 10 possible ...
3
votes
1answer
58 views

How write query in “Select_analysis” that compare string from one column with another column?

I have a shp file (s.shp) with column "A" and column "B". I try copy from this file only that rows where string value from column "A" is part of string value from column "B" e.g. A 0.1 0.2 0.3 ...
1
vote
1answer
29 views

Add multiple fields to attribute table by python, with a prompt window for parameters

I know how to add field to arcmap shapefile using Python: import arcpy arcpy.env.workspace = "H:\pythonexercise\NZL_rds\NZL_roads.shp" arcpy.AddField_management("NZL_roads", "LENGTH", ...
0
votes
1answer
51 views

Unable to load shapefile as feature class into geodatabase file, with only 3 of the fields

I'm trying to automate importing census boundary shapefiles to feature class in a Geodatabase File, but somehow could not get it to work with this code: ### ======================== load boundary ...
0
votes
0answers
37 views

how to create a shapefile containing attributes from a list?

I have a list of features and each feature is a dict in that list. following you can see the structure: [ {"FID": 0, "Shape": polyline, "Nodes": [0,1]}, {"FID": 1, "Shape": polyline, "Nodes": ...
0
votes
0answers
26 views

Unable to load shapefiles fully using shapefile.py

I am trying to load my shapefiles directly via Python rather than loading them from Arc Catalog to ArcMAP. I load these modules first: import sys import os import arcpy import numpy Then I add a ...
0
votes
1answer
34 views

Clip a shapefile based on raster extent with high accuracy

I am trying to clip a shapefile based on the extents of a smaller raster. I find the extent of the raster using this code: Extents = arcpy.sa.Raster(MyRaster).extent` Then, I use these lines to ...
1
vote
1answer
44 views

how to separate a list of features from its shapefile_

I tried to copy all features in a list of dictionaries. the code looks as follows: def iterate_features(self): feature_set = arcpy.SearchCursor(self.address) for feature in feature_set: ...
1
vote
2answers
36 views

finding the index of a field with its name using arcpy

I wan to extract the index of a field with its name using arcpy. it seems what I have written is so dumb. is there any simpler method with out using for-loop. import arcpy fieldList = ...
1
vote
1answer
84 views

Converting Coverage files into shapefiles?

I am attempting to convert coverage files into shapefiles using arcpy. This is not the e00 files, but the bin files. ArcGIS help suggests that it can be done using ...
3
votes
0answers
95 views

How to extract zipped shapefile and check its shape type using arcpy module without writing on disk

I have a zipped shapefile saved on my disk. I want to extract it in memory and check the shape type. I'm using arcpy module and want to stick to only default modules comes with python installation. I ...
1
vote
2answers
384 views

Creating a new feature class with python and then adding attibutes

I am having trouble adding rows to a shapefile after it has been created. I'm not sure if I need to create the shapefile in memory and add the data or creating then re-open the file. While I've ...
1
vote
1answer
156 views

Arcpy ERROR 000732 when ApplySymbologyFromLayer

I want to split a shapefile by certain attribute and then apply a symbology layer, finally output it as a KMZ file. R1 = outpath + 'R1.lyr' arcpy.MakeFeatureLayer_management(fc, R1, "WHERE CAUSE") ...
3
votes
1answer
76 views

How to find number of fields in shapefile using Python?

I've been looking at the ArcGIS resources for python but I can't seem to figure this one out. I'm looking for a method to gain access to the number of fields that are within a shapefile / feature ...
1
vote
2answers
233 views

How to add shapefile as layer to map using Python and ArcPy?

I am working on an application and I am a beginner in Python :( I want to add a shapefile, the execution is successful and everything but no result appears on ArcMap, here is the code I use: import ...
0
votes
1answer
145 views

How to read shapefile of road segments into Python data structure to get begin and end point coordinates? [duplicate]

How can I take a shape file that has road segments and read it into a data structure in python that I can use to get begin and end points with? For example x, y to x2, y2. It's not a large shape ...
1
vote
1answer
245 views

How to convert shapefile to KML file using ArcPy? [duplicate]

Python script that checks to see if a specific layer file exists in the current workspace and, if it does, converts the layer file to a KML file. Does it work with a shapefile? Code so far: for file ...
2
votes
2answers
557 views

How to select specific filenames nested within several folders?

I have hundreds of shapefiles that are stored in separate folders, which are nested within several other folders. Among the shapefiles I only need the ones that are named 'POINT*.shp' How do I get ...
2
votes
2answers
68 views

Accessing features via arcpy

i try to use arcpy to accessing the features of a shapefile. I tried to use a searcheCursor, like that: cursor = arcpy.da.SearchCursor(Points, ["SHAPE@XY"]) for row in cursor: x, y = row[0] ...
2
votes
1answer
158 views

How to check if a shapefile is empty with arcpy

I have a bunch of shapefiles in a folder. But some of them are empty, i.e. there are no rows within the shapefile. Is there a simply to find those empty shapefile out?
3
votes
1answer
313 views

How to convert all shapefiles in folder into KML using ArcPy?

I was trying to convert all the shp in a folder into kml. featureclasses = arcpy.ListFeatureClasses() for fc in featureclasses: # Set Local Variables composite = 'COMPOSITE' pixels = ...
1
vote
2answers
975 views

How to loop through a list of shapefiles and rename them?

I am trying to upgrade a simple script to list all shapefiles in a folder and if necessary in any folders within and then loop through the list of shapefiles and rename them. import arcpy # Set ...
0
votes
2answers
286 views

Help writing script using a shapefile - select by attribute

I am trying to take an existing shapefile and narrow down the attributes using the 'select by attribute' The problem I am trying to solve is: Find parcels that have an acreage >= 100. The code I ...
9
votes
6answers
401 views

How to programmatically check if the number of shapes = number of table records?

I have a handful of approximately 1000 shapefiles that are corrupted (see attached error message). The shapefiles were generated from eCognition Developer 8. There is a script tool that seems to ...
0
votes
0answers
166 views

How to convert shapefile to tpk using python(ArcGIS 10.1)?

I'd like to convert shapefile to tpk using Arcpy.I surf in ArcGIS 10.1 help but i couldn't find any desire reference to help me . How can i convert shapefile to tpk using arcpy ? which function i need ...
1
vote
2answers
841 views

How to Add Shapefile with Symbology from Layer File to ArcMap MXD using ArcPy/Python?

Say I have a Shapefile: C:\DATA\points.shp A layer file: C:\SYMBOLOGY\symbology.lyr And a map document: C:\MAPS\map.mxd How can I add points.shp to map.mxd with the properties of symbology.lyr ...
3
votes
2answers
563 views

Csv to Shp conversion? [duplicate]

I am working on a really big script right now where I have a csv file that I have removed rows and columns from, and edited the headers. I need to create one big shapefile for the entire csv file then ...
1
vote
1answer
111 views

Arcpy CreateUniqueName usage: keep original input names

This is a continuation of the question I asked here: At this point I'm really just trying to get everything in one place and keep the original shapefile basename. I'll tackle merging like-named ...
5
votes
1answer
606 views

Using ArcPy to batch merge based on shapefile name?

ArcGIS 10 SP4 Python 2.6.5 I have quite a few shapefiles that are in many different directories. I'd like to pull out groups of like shapefiles, merge them, and move the results into a FGDB. I've ...
3
votes
2answers
573 views

How to overwrite a Shapefile

I want to be able to overwrite a shapefile if it exists. I think my code needs some tweaking. I am using v10. I am able to delete the actual .shp file but the .dbf, .shx, etc still remain, so if I try ...
2
votes
1answer
415 views

Create a shapefile from geometry

Please excuse my lingo, I am still learning some aspects of geo spatial and arcpy. I have a python script that takes a shapefile. The shapefile consists of a polyline. I have traversed the polyline, ...
3
votes
1answer
153 views

shapefile batch clip and merge combined

I have two shapefiles, one is polyline, the other polygon. For each polygon I would like to clip the polyline vectors inside. Using arcpy I already found part of a possible solution: ...
6
votes
3answers
207 views

Are there any open source Python modules compatible with arcpy that will allow complex SQL queries?

I am trying to handle string (non-geometry) duplicates in a large attribute table of a shapefile without having to convert to gdb and back or connect to a postgres db. I need to be able to use a count ...
1
vote
2answers
463 views

Arcpy (10.0) and centroids/points shapefile

I'm trying to create a point shapefile from a grid index polygon shapefile I created using arcpy. I know this is simple, but could anyone give a few pointers out there. Here is what I've done now: but ...
3
votes
1answer
565 views

Automate removal of duplicate polygon nodes from shape file in Arcmap

I have a whole lot of polygon shape files, many of which have got duplicate nodes. This makes processing difficult as almost all tools (erase, union, calculate area) do not work. I found that by ...
4
votes
2answers
726 views

Python - Check for number of shapefiles in a directory

I want to test: to see whether or not ONE AND ONLY ONE shapefile (which will be based on a filename wildcard) exists in a directory. Add these shapefiles to a list Use this list variable as an ...
4
votes
2answers
3k views

Arcpy - How do I specify the precision and scale of a new field?

I'm wanting to create a field with a maximum of 1 decimal place and then calculate a value into it: (I know that all my values are < 10) arcpy.AddField_management('C:/shapefile.shp', 'myField', ...
7
votes
3answers
4k views

How to include variable in where clause of arcpy.Select_analysis?

I am trying to loop through a shapefile, selecting each feature in turn and copying it to a temporary shapefile to by included in a union analysis. I'm using a cursor to find the ID name for each ...
5
votes
1answer
2k views

How to programmatically add shapefile to data frame in Arcmap

I have a toolbox with python script which creates a shapefile from JSON txt file, but it does not show the generated shapefile in arcmap, i have to add it from the output location. What code shall I ...
4
votes
2answers
2k views

Check if shapefiles exists in folder

In ArcGIS modelbuilder I want to check if a shapefiles exists, if not I want to create the shapefile in that folder. I guess the calculate value tool within ArcGIS modelbuilder can be used, but I need ...
2
votes
1answer
168 views

Using ArcPy to fetch Information from a .GDB

I am new to GIS and I would appreciate if you could guide me a little. I have a .gdb folder with data and I need to process that data to find educational institutions which are within say X Km of the ...
6
votes
1answer
1k views

Get shape filename in attribute field using field calculator

I apologize for crossposting against the ESRI geoprocessing forum, but it seems like this one gets answers. I'd like to have a modified append tool (ArcToolbox) that takes multiple shapefiles with ...
4
votes
1answer
3k views

How to add field in attribute table by python

I have research on the question (How to add an attribute field to an existing Shapefile via Python) but could not implement it. If you can give me examples on how to add field name in attribute ...
9
votes
3answers
8k views

How to create a shapefile in ArcGIS 10 using arcpy?

How can I create a shapefile using Python in ArcGIS 10? I have lat & long. From this I need Python code which will create a shapefile and display it in ArcGIS 10. Thanks.
7
votes
2answers
584 views

Reordering polygon shapefile permanently?

I've written a script which produces a polygon shapefile of the extents of all the thousands of rasters in our library. I want to organise the FID so that the files with the largest extents are on the ...