In order to upload csv to FusionTables, you'll need to make sure you authenticate first. I see you've included the dependencies for OAuth, but if you're just trying to have a script do a simple upload, it'd be easiest to use ClientLogin (and you don't need the dependencies). A skeleton of the code should look something like this (adapted from the sample code in the python library you referenced):
from authorization.clientlogin import ClientLogin
from sql.sqlbuilder import SQL
import ftclient
from fileimport.fileimporter import CSVImporter
token = ClientLogin().authorize(username, password) #Replace with your username and password (or prompt for them would be more secure)
ft_client = ftclient.ClientLoginFTClient(token) #ft_client needs to be used from here on out to make any calls to the FusionTables SQL API
#If you want to CREATE a table from the csv...
tableid = int(CSVImporter(ft_client).importFile("data.csv")) #Replace with your csv data source (or prompt for the location would be less hard-coded)
print tableid #This will print out the ID of your new table, but the table should also show up in Google Docs for the username you used to authenticate.
If you want to add rows to an existing FusionTable, that'll be trickier. It would probably take parsing out the CSV with csv.DictReader
or something and then iterating over that and uploading those rows using something like...
#update row using dictionary of values
print ft_client.query(SQL().update(tableid, cols={'strings': 'mystring3'}, row_id=rowid))
print ft_client.query(SQL().select(tableid))
...for each row.
This answer is 3 years late so you've probably got a workaround by now. But for completeness, here's an arcpy method to measure the distance between 2 objects.
Geometry has a method distanceTo
which:
Returns the minimum distance between two geometries. If the geometries
intersect, the minimum distance is 0.
Both geometries must have the same projection.
Best Answer
it is not realy complicated, look at Memory provider in vector: :
QgsPoint(x,y)
andQgsGeometry.fromPoint(QgsPoint(x,y))
QgsGeometry.fromPolyline([QgsPoint(x1,y1),QgsPoint(x2,y2)]))
QgsGeometry.fromPolygon([[QgsPoint(x1,y1),QgsPoint(x2,y2), QgsPoint(x3,y3)]])
1) two points:
2) the line connecting the two points
3) a polygon covering the points
-
Changes in QGIS 3.0 and onward:
For QGIS 3.0 and onward the above workflow is still correct, but certain functions have changed. See https://qgis.org/api/api_break.html
To update the above code, change following functions: