Tag Info

Hot answers tagged

4

This is a GDAL/OGR Python gotcha. So when you use print inputlyr[0].GetGeometryRef(), the reference to the indexed feature has been cleaned up before geometry functions can be used. This is expected behaviour, and there is no roadmap to change it. The issue is that the GDAL/OGR Python bindings are over a decade old, and are tightly coupled with the ...


3

Example for point layer def FindLabel ( [FID] ): mxd = arcpy.mapping.MapDocument("CURRENT") layers=arcpy.mapping.ListLayers(mxd, "ac_pipes_aspoints") lr=layers[0] with arcpy.da.SearchCursor(lr, 'Shape@XY',r'"FID"='+str( [FID] )) as cursor: for row in cursor: a=row[0] return a[0]


3

You don't need constraints for PostGIS 2.x, just us typmods. For 2D geometries with SRID=4326, the typmod is geometry(Geometry,4326). Or for M-dimension geometries, it would be geometry(GeometryM,4326) (you get the idea). Example: create temp table sometable(wkt geometry(Geometry,4326)); -- works insert into sometable(wkt) values('SRID=4326;POINT(1 2)') ...


2

For this, you need to create new ogr features and save them to the layer and not simply create geometries ( geom1.AddPoint(linkpoint[0],linkpoint[1]), feature1.SetGeometry(geom1)), with dataSource.SyncToDisk() at the end (SyncToDisk() might be helpful to ensure that a particular feature is flushed to disk but it is not necessary here, look at the script). # ...


2

@BradHards is right. Having mixed types is probably going to cause problems down the road. If you're sure your tools can handle mixed types, or you're going to be retrieving them some other way (through DB views, or programatically) you can split the constraints into two parts, either of which is optional: To modify your existing table -- Only check the ...


2

I disagree that QGIS always uses multipoint. If you use the Extract Nodes tool, you get a single point layer, and converting Multipart to singlepart and back changes the geometry type as expected. You can run ogrinfo on the shapefiles to check the geometry type. Unfortunately, QGIS reports the layers metadata always as Point.


1

Here are your starting shapes: At one billionth (10^9) of a degree precision (the same scale as your coordinates in the WKT), I receive a self-intersection error from the Esri geometry library. The geometry really is invalid as presented. If I increase the precision to 10 billionths (10^10), I get long slivers in the middle of the shape: If I back the ...


1

When I have a layer with errors , I normally run it through the GRASS function v.clean in the Processing Toolbox. Though I never really figured out which tool is best in which case, I normally choose the bpol function there. Maybe even more important it is to set the advanced parameters for snap tolerance and min area. Depending on the layer, I usually ...


1

Given Paul Ramsey's excellent explanation of why the next question is what can be done about it. How do you SELECT DISTINCT on geometry fields and have it perform as expected? In Paul's answer, I proposed using SELECT MAX(geom) FROM the_table GROUP BY ST_AsBinary(geom); but MAX() is slow, apparently requiring a table scan. Instead, I found this to be ...


1

(Credit to @Russell at ISC for the use of the modulo operator.) We have a table in SQL Server with a column of geography data type, called [GeoCoor]. This is how we convert to degrees, minutes, and seconds: SELECT [GeoCoor].[Lat] as [DecimalLatitude], floor(ABS([GeoCoor].[Lat]))*(CASE WHEN [GeoCoor].[Lat] < 0 then -1 ELSE 1 END) as [LatDegrees], ...



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