Skip to content

Instantly share code, notes, and snippets.

View antoniolocandro's full-sized avatar

Antonio Locandro antoniolocandro

View GitHub Profile
layer = QgsProject.instance().mapLayersByName('replacement_table')[0]
test = QgsProject.instance().mapLayersByName('test')[0]
#print (layer.name())
#print (test.name())
feat = layer.getFeatures()
seat = test.getFeatures()
@antoniolocandro
antoniolocandro / ogr_gfs_geom_types.md
Created December 15, 2020 21:12 — forked from walkermatt/ogr_gfs_geom_types.md
List of geometry type codes that can specified in an ogr gfs file.

OGR GFS Geometry Values

The geometry type of a feature class can be specified in a .gfs file used by OGR to map from a GML document to a simple feature schema. The following numbers can be used to specify a specific geometry type:

-2147483647 Point25D
-2147483646 LineString25D
-2147483645 Polygon25D
-2147483644 MultiPoint25D
-2147483643 MultiLineString25D

-2147483642 MultiPolygon25D

@antoniolocandro
antoniolocandro / vincenty
Last active April 11, 2016 22:03 — forked from jtornero/vincenty
Python implementation of Vincenty's direct formula
def vinc_pt(f, a, phi1, lembda1, alpha12, s ) :
import math
"""
Returns the lat and long of projected point and reverse azimuth
given a reference point and a distance and azimuth to project.
lats, longs and azimuths are passed in decimal degrees
Returns ( phi2, lambda2, alpha21 ) as a tuple
Parameters:
===========
f: flattening of the ellipsoid
@antoniolocandro
antoniolocandro / bbox
Last active August 29, 2015 14:23
QgisCommand
from qgis.utils import iface
from qgis.core import QGis
from qgiscommand.command import command
@command()
def bbox():
layer = iface.activeLayer()
def pbounds (Lextent,s):
e = Lextent
@antoniolocandro
antoniolocandro / gist:e478aba6c1070aa87ead
Created January 26, 2015 23:06
Postgis Buffer quad
SELECT airport_heliport.gid, airport_heliport.designator, ST_Buffer(st_makepoint(st_x(airport_heliport.geom), st_y(airport_heliport.geom)), 18520, 'quad_segs=32') AS geom FROM gis20141211.airport_heliport;
rec=0
def autoIncrement():
global rec
pStart = 0 #adjust start value, if req'd
pInterval = 50 #adjust interval value, if req'd
if (rec == 0):
rec = pStart
else:
rec = rec + pInterval
return rec
@antoniolocandro
antoniolocandro / arcgis-label-expression-2013120501
Created December 5, 2013 16:19
How to round and add a superscript to a Label Expression in ARCGIS
[name]&vbnewline& round( [sqKM])&" Km<sup>2</sup>"
@antoniolocandro
antoniolocandro / WGS-Area-km2
Created December 5, 2013 15:50
Calculate area of polygon in GCS WGS 84 in Km2 using POSTGIS ST_Area
-- Calculate Km2 of a polygon stores in GCS WGS84
-- by default ST_Area returns the calculation in meters so the appropriate conversion was applied
-- fir_area_20131205 was the example table used
-- the spatial data was in a geom field so geom::geography was added
SELECT ST_Area(geom::geography)/1000000 as sqKM from fir_area_20131205
@antoniolocandro
antoniolocandro / test_area
Last active December 30, 2015 09:09
Compare ESRI WGS84 degree area calculation with POSTGIS
-- Test to compare the area calculation in degrees when data is stores as WGS84 in ESRI vrs POSTGIS
select shape_area as ESRI_area, ST_Area (geom) as POSTGIS_area, (shape_area-(ST_Area (geom)))*100 as Percentage_Difference from fir_area_20131205