POST
|
That's amazing! No I didn't know about this. It seems that it will definitely do the job for me... I just hope it can handle large numbers of zones. Thanks a million
... View more
06-12-2014
02:17 AM
|
0
|
0
|
326
|
POST
|
I have a polygon layer of regularly spaced, overlapping buffers, created by buffering points 400m apart, with buffers of a 400m radius. But now I need to split this into separate polygon layers in which the buffers do not overlap, in order to use zonal statistics with raster layers (if the polygons overlap the zonal statistics doesn't work properly). By manually selecting the first few buffers I have found that four layers would suffice to contain all the buffers with no overlaps within each of the four new layers. My problem is how to select the buffers that I want to export to new layers. I don't have a regular number of polygons on the x or y axis and I tried generating a point layer to use select by location but I couldn't get the right spacing, it was very fiddly. I have attached an image with the four separate layers on top (which I extracted manually) and the overlapping polygon layer (which I extracted them from) on the bottom. I can't do all the extractions manually as I have 800,000 polygons! Any suggestions? I don't know python but this could be programmed I'm sure with a python script. I just don't have the first clue!
... View more
06-11-2014
07:44 AM
|
0
|
2
|
688
|
POST
|
Yes I have downloaded the new toolbox :). I was already running the first script tool to create rasters for a subset of approx 600 points - it took 28 minutes! But yes, they are shifted to the right. How can I correct this? I'm afraid to start messing about with your beautiful script! Also the files came out with names 'dist_0', 'dist_1' etc., but I need them to take the VISITID code from the VISITID field in the point layer to be able to join this data with other datasets. This was in the very original script that you wrote. Would this be simple to do? Sorry to take up more of your time!
... View more
08-09-2013
09:01 AM
|
0
|
0
|
164
|
POST
|
One more note...The lines highlighted in blue may need to be changed to + instead of - depending on the units...I had to subtract 2 cell sizes to make sure it was centered. Could you just explain this a bit more please? Why did 2 cell sizes need to be subtracted and what will affect this? My units will always be meters. I'd like to be sure I'm using the script correctly, and be able to check it has worked. Thanks!
... View more
08-09-2013
08:44 AM
|
0
|
0
|
896
|
POST
|
Wow, this is incredible! Thank you so much! I will cite your tool in any papers I submit. I actually only need the ascii file as I can read this into R where I am doing my analysis. Currently I am reading in the rasters so I can just alter this line of the R script for the different file type! So do I just remove this part of the code: # ascii to raster
Message('converting ascii files to raster...this may take a while')
arcpy.env.workspace = ws
for txt in arcpy.ListFiles('tmp*.txt'):
number = int(''.join(n for n in txt if n.isdigit()))
out = os.path.join(outws, 'dist_%s' %number)
if arcpy.Exists(out): arcpy.Delete_management(out)
arcpy.ASCIIToRaster_conversion(txt, out)
arcpy.DefineProjection_management(out, SR)
arcpy.Delete_management(txt)
arcpy.Delete_management(txt[:-4] + '.prj')
# delete templates and ascii folder
for txt in arcpy.ListFiles('ascii_*'):
arcpy.Delete_management(txt)
os.rmdir(ws)
... View more
08-09-2013
08:28 AM
|
0
|
0
|
896
|
POST
|
Wow, this is amazing thank you! You're right, I have unnecessary no data cells for my whole extent. Thanks for your time and effort, I don't know what I would have done without your help! Interestingly, yesterday I reran the original script on data from one county (560 points) and it was racing through the script- it took only 30 minutes! The things I changed were - 1) output raster format to .img and 2) scratch workspace from default geodatabase(! - don't know why that was the default) to c:\temp. It was really quick even though the extent was still for the whole country. Nevertheless I would still like to use your buffer version to reduce file size, but I got the following error: Runtime error
Traceback (most recent call last):
File "<string>", line 32, in <module>
AttributeError: DescribeData: Method extent does not exist Thanks again
... View more
08-09-2013
12:45 AM
|
0
|
0
|
896
|
POST
|
One last idea, how should I change this line query = '{0} = {1}'.format(arcpy.AddFieldDelimiters(points,'VISITID'),i) to change VISITID to the field selected via the tool dialogue box?
... View more
08-08-2013
06:28 AM
|
0
|
0
|
896
|
POST
|
Now it creates an output but the raster values are strange (they are not the same as when I run the script with hard-coded paths) and it also doesn't save to the location I am specifying, so I'm still doing something wrong! I may give up on creating a script tool with this. More important than this is the processing time issue. Is there a way I could batch process subsets of my points file and run them simultanously outside of ArcGIS with a Python programme?
... View more
08-08-2013
06:19 AM
|
0
|
0
|
896
|
POST
|
Sorry I noticed I missed the 'da' in searchcursor. So I ran it again with this corrected and got the following error: Messages Executing: IterativeEuclideanDistance C:\Docs\ArcGIS\Dorset_sample.shp VISITID C:\Docs\ArcGIS\DORSET Start Time: Thu Aug 08 14:32:28 2013 Running script IterativeEuclideanDistance... Traceback (most recent call last): File "C:\Docs\ArcGIS\Scripts\IterativeEucDist.py", line 24, in <module> eucDist.save('dist_%s' %i) RuntimeError: ERROR 010093: Output raster format UNKNOWN is unsupported. Failed to execute (IterativeEuclideanDistance). Failed at Thu Aug 08 14:33:10 2013 (Elapsed Time: 42.00 seconds)
... View more
08-08-2013
05:34 AM
|
0
|
0
|
880
|
POST
|
Thanks for your reply! I got the following error message: Messages Executing: IterativeEuclideanDistance C:\Docs\ArcGIS\Dorset_sample.shp VISITID C:\Docs\ArcGIS\DORSET Start Time: Thu Aug 08 14:25:23 2013 Running script IterativeEuclideanDistance... Traceback (most recent call last): File "C:\Docs\ArcGIS\Scripts\IterativeEucDist.py", line 15, in <module> ids = list(r[0] for r in arcpy.SearchCursor(points,[field])) File "C:\Docs\ArcGIS\Scripts\IterativeEucDist.py", line 15, in <genexpr> ids = list(r[0] for r in arcpy.SearchCursor(points,[field])) TypeError: 'Row' object does not support indexing Failed to execute (IterativeEuclideanDistance). Failed at Thu Aug 08 14:25:23 2013 (Elapsed Time: 0.00 seconds)
... View more
08-08-2013
05:29 AM
|
0
|
0
|
880
|
POST
|
I attempted to turn the script into a custom tool, but can't get it working. The problem seems to be with how to replace 'VISITID' as a specified field, to use instead the field that is selected in the dialogue box. Can you take a look at my script to see what I'm doing wrong? import arcpy from arcpy import env arcpy.CheckOutExtension('Spatial') from arcpy.sa import * # set parameters (needed for dialgue box) points = arcpy.GetParameterAsText(0) field = arcpy.GetParameterAsText(1) # set output workspace outWorkspace = arcpy.GetParameterAsText(2) arcpy.env.overwriteOutput = True # oid field and list of id's ids = list(r.field for r in arcpy.SearchCursor(points)) # loop through table to make a distance raster for each point # EucDIstance(points, max_distance, cell_size) <-- parameters lyr = arcpy.MakeFeatureLayer_management(points, 'points_lyr') for i in ids: query = '{0} = {1}'.format(arcpy.AddFieldDelimiters(points, field),i) arcpy.SelectLayerByAttribute_management(lyr, 'NEW_SELECTION', query) eucDist = EucDistance(lyr, 10000, 1000) eucDist.save('dist_%s' %i) print 'Created Euclidean Distance raster for point ID: %s' %i print 'Done' Thanks
... View more
08-08-2013
03:53 AM
|
0
|
0
|
880
|
POST
|
Is it absolutely necessary to have an individual raster for each point? Yes, I need one raster per point as I want to find out distance weighted population surrounding each point. Also my points are very dense in some places with only a few meters between, so there would be an overlap whatever distance cut off I decide to use.
... View more
08-08-2013
01:41 AM
|
0
|
0
|
880
|
POST
|
So I just ran the script on a sample of 10 points and it works perfectly. However, it took 10 minutes for 10 points, so a quick scaling up led to an estimate of one month to run on 45,000 points! Is there any alternative, more efficient way? Thanks again.
... View more
08-07-2013
09:47 AM
|
0
|
0
|
880
|
POST
|
Thank you for your quick reply and for providing code! I shall try it out and let you know. With gratitude
... View more
08-07-2013
09:21 AM
|
0
|
0
|
880
|
POST
|
Hi, I am completely new to Python, but need to turn to it due to the nature of my research. I have a point shapefile with 45,000 points ('visits') spread across the UK and I want to obtain a euclidean distance raster (with a cut off of say 100km). I know the tool I need to use to create the distance raster is Euclidean Distance, but I need to iteratively select each point (by 'visitID') from the shapefile and create a distance raster for each one in turn. Can anyone direct me to useful resources or share their scripting wisdom? Thank you in advance!
... View more
08-07-2013
08:27 AM
|
0
|
22
|
4938
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|