I have a .csv file with 3 fields: lat, long, and value. I'd like to create a Thiessen Polygon raster from this file in Python without creating intermediate datasets. Here's what I have:

# Create layer from points
arcpy.MakeXYEventLayer_management(points_file, 'lon', 'lat', "points_lyr", arcpy.SpatialReference(4326))

# Make polygons
arcpy.CreateThiessenPolygons_analysis("points_lyr", "tp", "ALL")

# Rasterize
PolygonToRaster_conversion("points_lyr", "grid_id", "weather_grid")

This fails at step 2, raising the following error:

arcgisscripting.ExecuteError: ERROR 000339: Input points_lyr does not have OIDs
Failed to execute (CreateThiessenPolygons).

Is it possible to create Thiessen polygons without first converting "points_lyr" into a shapefile?


You can use arcpy.FeatureClassToFeatureClass_conversion() to create a new dataset that will have OIDs, and if you are worried about having to clean up temporary datasets afterwards, you can do it all in memory. Of course if the dataset is ridiculously huge, this could exhaust memory, but most systems will hold reasonably large datasets in memory.


arcpy.FeatureClassToFeatureClass_conversion("points_lyr", "in_memory", "pointsFC")

After you've finished with the temporary feature class, if your script has much other work to do, you should delete it to free up memory, eg with:


Although if you're going to explicitly delete the feature class anyhow, then you can just create it as a shapefile (or in a fGDB) instead of in memory. In memory is substantially quicker for some operations, but you have to weigh that up against how much memory is available/required.


In these cases I usually will pull the "points_lyr" into a new feature class, which will create a new ObjectID field; then run my geo-process.

Yes, it seems silly; but I have found it to work consistently.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.