New answers tagged

0

There are many solutions pts = gpd.GeoSeries([Point(2,3),Point(3,2),Point(1,1)]) distances = [ (i, pt.distance(Point(0.99,0.99))) for i, pt in enumerate(pts)] print distance [(0, 2.2494888308235717), (1, 2.2494888308235717), (2, 0.014142135623730963)] print min(distance,key=lambda item:item[1]) (2, 0.014142135623730963) or from operator import ...


0

You could: Simplify the geometries of your large polygon shapefile: Vector > Geometry Tools > Simplify Geometries... Select only those features from the large polygon shapefile which intersects the single polygon: Processing Toolbox > QGIS geoalgorithms > Vector selection tools > Select by location Then use these selected features for ...


2

This field calculator expression took 0.65 seconds to populate new field by 1 - first occurrence or 2 - twin in 10000 large table. aDict={} def FirstOrNot(a,b): key=tuple(set([a,b])) if key in aDict: return 2 aDict[key]=0 return 1 --------------------------- FirstOrNot(!FID!, !NEAR_FID! ) This is a very big zoom: Points symbolised by this ...


2

I think the most inefficient part of your code is Select by Attribute part which requires relatively high overhead to add marked item to your current selection. First create a new SHORT field in your table to mark the desired pairs. And then I suggest you to first create a Python set with row[0] and row[1] as converted to string and with a delimiter first, ...


0

If you're able to execute import arcpy in under 4 seconds, the DLL files are already cached in memory, and that's as fast as you can hope to achieve. It's a very large library, and it takes Python a while to read and register. The best way to reduce repeat import cost is to not exit().


0

Does it have to be a view? Some expensive operations, like this spatial filter, are best handled in ETL, or in a scheduled task in MSSQL. If it needs to be real-time, then I guess you'll have to put up with some slowness. If you can handle data that is a day old, set up a task to cache the data.


1

In response to @crld I have done some tests, Im not sure if im doing the timings right but, the first method doesnt actually work, it breaks out of the loop after 1 iteration import arcpy import itertools fc = r'D:\randomstuff\test2.gdb\Point0' #5146 points fc1 = r'D:\randomstuff\test2.gdb\points2' #484 points def printCount(start,count): end = time....


4

Logically, they do effectively the same thing. For every row in one data set, loop through every line in one dataset (presumably until some criteria is satisfied, then break). Without a break on an if statement, if both datasets are 10,000 rows long, you would have to iterate through 100,000,000 rows. EDIT: However, the With With For For methodology doesn'...


1

In the Postgis connection settings, selecting the "Don't resolve type of unrestricted columns (GEOMETRY)" checkbox usually helps.


1

If you're using ArcGIS 10.1 or above, you can use data access cursors. You can also remove your second outer loop by doing all the same stuff within the first loop. You don't need to reset the arcpy workspace to the same path twice. As I commented above, you pretty much never want to use try/except, until you have your script working properly. I've added ...



Top 50 recent answers are included