Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #94112 > unrolled thread

batch spatial join - python

Started byLara BK <laritaba@gmail.com>
First post2015-07-19 05:11 -0700
Last post2015-07-19 23:55 +1000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  batch spatial join - python Lara BK <laritaba@gmail.com> - 2015-07-19 05:11 -0700
    Re: batch spatial join - python Steven D'Aprano <steve@pearwood.info> - 2015-07-19 23:55 +1000

#94112 — batch spatial join - python

FromLara BK <laritaba@gmail.com>
Date2015-07-19 05:11 -0700
Subjectbatch spatial join - python
Message-ID<044a0f78-91fe-4730-945a-8b6456e32d9d@googlegroups.com>
Hello, 

I would like to do a spatial join in a batch process in python. 

# I have this layers: 

neighbourhood = "D:\\Users\\laraifat\\Desktop\\pythonproject\\layers\\neighbourhood.shp"
buildings = "D:\\Users\\laraifat\\Desktop\\pythonproject\\layers\\buildings.shp"
openspace = "D:\\Users\\laraifat\\Desktop\\pythonproject\\layers\\openspace.shp"
buses = "D:\\Users\\laraifat\\Desktop\\pythonproject\\layers\\buses.shp"
education = "D:\\Users\\laraifat\\Desktop\\pythonproject\\layers\\education.shp"
health = "D:\\Users\\laraifat\\Desktop\\pythonproject\\layers\\health.shp"
sport_point_shp = "D:\\Users\\laraifat\\Desktop\\pythonproject\\layers\\sport_point.shp"

#I created this variables with the layers:

input_features = [sport_point_shp, health, buses, education] #the layers that will be used to count the buildings inside the neighbourhood layer
new_layers = ["join_sport", "join_health", "join_buses", "join_education"] # the layer that will be created after join 

arcpy.BatchSpatialJoin_analysis(neighbourhood, input_features, new_layers, "JOIN_ONE_TO_ONE", "KEEP_ALL", "", "INTERSECT")

#### but when i run the script is says:

Runtime error 
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'BatchSpatialJoin_analysis'


How can i solve this problem? 

Thank you! 

[toc] | [next] | [standalone]


#94117

FromSteven D'Aprano <steve@pearwood.info>
Date2015-07-19 23:55 +1000
Message-ID<55abac4f$0$1642$c3e8da3$5496439d@news.astraweb.com>
In reply to#94112
On Sun, 19 Jul 2015 10:11 pm, Lara BK wrote:

> I would like to do a spatial join in a batch process in python.


You seem to be using arcpy. Unfortunately, that's not a standard part of
Python, so I don't know it very well. But looking at the error you get:


> Traceback (most recent call last):
>   File "<string>", line 1, in <module>
> AttributeError: 'module' object has no attribute
> 'BatchSpatialJoin_analysis'

it looks like the line starting with this:

arcpy.BatchSpatialJoin_analysis(neighbourhood, blah-blah-blah...)

is misspelled. Are you sure that it's called *Batch* SpacialJoin_analysis?

Looking at this page:

http://help.arcgis.com/en/arcgisdesktop/10.0/help/0008/00080000000q000000.htm

I think you might need to change it to:

arcpy.SpatialJoin_analysis(neighbourhood, blah-blah-blah...)


Does that help?




-- 
Steven

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web