Tag Info

Hot answers tagged

5

I can crush this down to 3 lines of code, no cursors required! import arcpy arcpy.SpatialJoin_analysis("Site", "points","in_memory/points_SpatialJoin", "JOIN_ONE_TO_MANY", "KEEP_ALL", "", "INTERSECT") arcpy.Statistics_analysis("points_SpatialJoin", "in_memory/stats", "Join_Count SUM","Id") Then simply sort the table to find the polygon with most points.


4

The following approach uses a Search Cursor and Python dictionary to perform the following workflow: Select points within each polygon feature Update dictionary with key (OID) and value (point count) for each iteration Find max point value and corresponding OID and write to a text file import arcpy, os points = r'C:\temp\mytest\points.shp' polys = ...


3

You don't need to create an extra field to do this. I can see the arcgis-desktop tag in the question. So the workflow in arcgis desktop is of the following: 1- Make a selection (Dates Over 2013) and export to a separate shape file. 2- Revert the selection and export to a separate shape file. Snapshots in ArcGIS:


2

With Fiona and shapely (in pure Python, no need of ArcPy or PyQGIS) from shapely import shape import fiona # reading the 2 shapefiles feat1 = list(fiona.open('point1.shp')) # list of dictionaries feat2 = list(fiona.open('point2.shp')) # find the linear distance between points that are paired by their site_code attribute data pairs = zip(feat1,feat2) print ...


2

ArcGIS GUI solution: Merge all points into one file Run Points to Line tool, using site_code as Line Field. If you save it to a geodatabase, SHAPE_LENGTH will be the distance of the line. Otherwise, calculate the length of the line yourself. ArcGIS (10.1+) field calculator solution: This matches points with the same 'site_code' between two files. ...


2

For PostGIS 2.1, you can just convert the geometry to a geography type, where longitudes are always normalised to the -180/+180 range. For example, take these coordinates that are outside the range, and compare the normalised output: SELECT ST_AsText(geom::geography::geometry) FROM (SELECT 'POLYGON((180.12 -16.69,180.00 -16.80,179.89 -16.95, ...


2

You can use ST_DumpPoints and iterate over its results. It should be exactly what you're looking for.


1

If you want to get the distance between two sets of lat/lon, 4326, points, then you can use ST_Distance_Sphere or for more accuracy, ST_Distance_Spheroid. If your fence table is in 900913, then use, ST_Transform to convert, so that both sets of points are in a common SRID. SELECT ST_Distance_Sphere( (select ST_Transform("Fence", 4326) FROM ...


1

If you are comfortable with Python you only need classic Python, list comprehensions and the understanding of PyQGIS: Geometry Handling: A Point in PyQGIS is built with QgsPoint(x,y); A LineString with QgsGeometry.fromPolyline([QgsPoint(x1,y1),QgsPoint(x2,y2)])) A Polygon with QgsGeometry.fromPolygon([[QgsPoint(x1,y1),QgsPoint(x2,y2), ...


1

You can take the extractPoints() function from the fTools plugin by Carson Farmer: # Generate list of QgsPoints from input geometry ( can be point, line, or polygon ) def extractPoints( geom ): multi_geom = QgsGeometry() temp_geom = [] if geom.type() == 0: # it's a point if geom.isMultipart(): temp_geom = geom.asMultiPoint() ...



Only top voted, non community-wiki answers of a minimum length are eligible