Hot answers tagged

12

You can add the CSV file, structured as below, as a layer using the following script: import numpy as np c = np.genfromtxt('C:/path/to/file.csv', delimiter=',') # check delimiter lats = c[:,0][1:] lons = -c[0][1:] # remove minus if you get a mirrored result data = c[1:,1:] crs = "EPSG:4326" # change if crs is different layer = QgsVectorLayer(&...


6

Drag&Drop your CSV-file into QGIS, so you can see it in Layers tab Use a "Virtual Layer" through Layer > Add Layer > Add/Edit Virtual Layer... with the following query SELECT make_line(setsrid(make_point(start_easting, start_northing),27700), setsrid(make_point(end_easting, end_northing),27700) ) AS geom FROM &...


5

Create a pandas dataframe from your data and use to_csv. A workaround, but you can choose whatever delimiter you want: import arcpy import pandas as pd fc = r'C:\GIS\data\Bakgrundskartor_LMV\Vagkartan.gdb\bs_riks' #fields = ['KKOD', KATEGORI','SRIKT'] #Either list the field names manually fields = [f.name for f in arcpy.ListFields(fc) if f.type not in ('...


4

When working with CSV's, sometimes is more efficient to preprocess them before ingesting them in QGIS. In this case, if I understand right, you want one "vector" (line feature) per line of data. So edit the CSV in Excel or OpenOffice or wherever you created it, to force the geometry you want using its WKT representation. In your instance, the ...


3

The documentation for the 'field' class explains that the .aliasName attribute holds the value of the field alias. So change the field_names = line to this: field_names = [field.aliasName for field in fields if field.name in fieldsToKeep] Or if you want to be a bit clearer, change it to this: field_aliases = [field.aliasName for field in ...


2

Points to path allows you to sort and group your points to lines. Sorting is line-specific, and lines are defined by grouping. So you could add a column containing 1s, another containing 2s, and a third containing incrementing numbers. When loading your data into QGIS, you load your starting points as one layer with the first line specific ID, and your end ...


2

There is an ArcGIS Pro Idea already submitted to Add More Delimiter Options in Table Export Tools (i.e., pipe delimiter): There are several existing tools to export a table to a flat file .txt or .csv, such as copy rows, table to table, or export features rows to ASCII. The last option at least gives you the ability to choose comma, space, or semicolon ...


2

You just need to make sure to read the values from each row in the desired order. Try this: fields = arcpy.ListFields(fc3) aliases = {field.name: field.aliasName for field in fields} fieldsToKeep =['REPORTER','RECOWNER','SCINAME','COMNAME','RECBASIS','GlobalID','OCCSTATUS','MANAGESTAT', 'POPSTAT','OBSDATE','COUNTRY','STATE','COUNTY','...


1

You cannot append new data into existing by just copy/paste or conversions. It will try to replace you existing table. If you have updated your table previously and you want to replace you existing table, all you have to do is to insert this line after importing arcpy. arcpy.env.overwriteOutput = True However you should take a look to append tool. Pay ...


1

arcpy.env.workspace = r"C:\\" using a raw string, the interpreter will escape backslashes, so this will result in 4 backslashes. Remove the "r" as you have to escape to form a valid string. >>> dir = r"c:\\" >>> dir 'c:\\\\' here you are also prepending a backslash to the file name, so this will end up with 5 ...


1

If you have the .tif files of soils classes you can read them in R as a raster stack and then use the exact_extract function from the exactextractr package, which is the fastest way around. An example code: library(exactextractr) library(raster) library(maptools) library(sf) ## Example SpatialPolygonsDataFrame data(wrld_simpl) #polygon of world countries ...


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