123
votes
Accepted
Converting Pandas DataFrame to GeoDataFrame
Convert the DataFrame's content (e.g. Lat and Lon columns) into appropriate Shapely geometries first and then use them together with the original DataFrame to create a GeoDataFrame.
from geopandas ...
73
votes
Accepted
Exporting attribute table to Excel from QGIS
QGIS v3.x
Right click on the layer in the Table of Contents (aka. legend or layer tree) and open the Save As... dialog.
Once there, click on the Format option list and choose MS Office Open XML ...
47
votes
Converting Pandas DataFrame to GeoDataFrame
Update 201912: The official documentation at https://geopandas.readthedocs.io/en/latest/gallery/create_geopandas_from_pandas.html does it succinctly using geopandas.points_from_xy like so:
gdf = ...
29
votes
Exporting attribute table to Excel from QGIS
To get a csv file of the attribute table, rightclick on the layer in the legend, select Save As ..., and change the file format from shapefile to CSV.
You might need to change the separator from ...
28
votes
Accepted
Join CSV file to shapefile using gdal/ogr
The ogr2ogr utility supports a limited sql syntax. You can join your CSV to the shapefile using something like the following:
ogr2ogr -sql "select inshape.*, joincsv.* from inshape left join '...
21
votes
How to model a graveyard - one point per deceased or one per grave?
I would go the complicated way:
Two Tables in a 1:n relation
one table with the point location of the graves
another table with the Grave-ID and person data
You can build a relation between the two ...
20
votes
Accepted
Creating buffer in meters
In step 4, you have to change the CRS from NAD83 to another projection that uses metres as units.
It depends on the extent of your data which one is best. Unfortunately, your data is located all over ...
19
votes
Accepted
Convert huge XYZ CSV to GeoTIFF
You can do this using GDAL, it directly supports XYZ format. It doesn't matter if your coordinates are UTM, gdal_translate will output in the same coordinate system.
So to convert to GeoTIFF is as ...
17
votes
Converting CSV file of WKT data to shapefile using ogr2ogr?
I had to solve the same problem today, so here is my answer, which gives a complete solution.
I have a lineWKT.csv file stored in F:\Data\ folder, with the data like this:
id,gm
0,"LINESTRING (30 10 ...
16
votes
Accepted
How to reproject 500 CSV files efficiently and easily using QGIS?
If you're looking to reproject csv files from the Python Console in QGIS then you could use the following script. All you would need to change are the three paths which are mentioned in the comments.
...
15
votes
Import unknown text polygon format to QGIS
Interesting. It is obviously not a CSV content, but a JSON.
If you use the following script to convert the file content to a layer in QGIS Python Editor, you get a polygon as in the image.
Edit: OK. ...
14
votes
Changing CSV layer attribute value from text to number in QGIS?
Instead of loading the .csv using Add vector layer, use the Delimited Text layer tool. It will try to detect the most fitting data type for each column.
For more details see the QGIS user guide.
14
votes
Listing all Feature datasets and feature classes from single Geodatabase into CSV
I think you should research/ask about writing to a CSV file separately at StackOverflow because the technique you are using to do that is pure Python rather than ArcPy.
For the remainder I think this ...
14
votes
Exporting attribute table to Excel from QGIS
In QGIS versions 3 and above, the easiest way to export an attribute table is to:
Right-click the attribute layer in the layers menu
Select Export and Save features as...
At the top of the program ...
13
votes
Join CSV file to shapefile using gdal/ogr
The accepted answer is really useful, but I found that it was slow with a large-ish database. I believe it also limits your options when joining the data.
My method now is to pull everything into ...
13
votes
Accepted
Handling KML/CSV with geopandas - DriverError: unsupported driver: u'CSV'
in case of csv, it probably would be easier to read it with pandas and then convert it to geopandas Dataframe
import pandas as pd
import geopandas as gp
from shapely.geometry import Point
stations = ...
13
votes
Seeking tool for converting JSON to GeoJSON or CSV
Look at the samples on the specification site. You'll need to write a script in the language of your choice that will get you from
[
{"date":"2014-09-25","time":"20:49:09","lat":"53.269","lon":"6.935"...
13
votes
Accepted
Converting csv to kml/geojson using ogr2ogr or equivalent command line tools?
According to the ogr2ogr csv documentation and also this answer, you need to specify which fields contain the geometry in a VRT file:
<OGRVRTDataSource>
<OGRVRTLayer name="test">
...
13
votes
Accepted
Loading multiple CSV files into QGIS 2.10
You could use the following code in the Python Console to locate your csv files in a specified folder and load them as point shapefiles using their longitude/latitude fields. The code assumes:
The ...
13
votes
Importing coordinates as CSV file, but points are not displayed
You are putting the x and y coordinates in wrong order. -8.183973 is latitude (Y) and 111.845623 is longitude (X). You need to adjust the column of X and Y to be Y and X, respectively. The coordinates ...
13
votes
Accepted
NameError: name 'QMessageBox' is not defined
This is a bug in NNJoin plugin.
Open NNJoin_gui.py file located in "/Users/joanlee/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/NNJoin/" using an editor.
Add ...
12
votes
Converting csv to kml/geojson using ogr2ogr or equivalent command line tools?
Starting with GDAL 2.1, it is possible to directly specify the
potential names of the columns that can contain X/longitude and
Y/latitude with the X_POSSIBLE_NAMES and Y_POSSIBLE_NAMES open option....
12
votes
Exporting attribute table to Excel from QGIS
There's also the MMQGIS Plugin which, when downloaded and installed from the toolbar (Plugins > Manage and Install Plugins...), has the tool:
MMQGIS > Import/Export > Attributes Export to CSV ...
12
votes
Accepted
Join and export .csv file as .shp in QGIS?
You don't want to export csv, you should Save as... the shapefile which you joined the csv to. If you export csv table (which was not loaded with points geometry), there won't be any geometry and thus ...
12
votes
how to visualize csv data every 10 rows in QGIS
Assuming you don't have a unique id field, you can use rule based symbols with the following filter
$id % 10 = 1
The % sign is equivalent to remainder, so any row that divides by 10 with a ...
12
votes
Accepted
Bulk csv to shapefile (using ogr2ogr)
A modern-enough GDAL can convert CSV files directly into shapefiles. For the test.csv file in the documentation, http://www.gdal.org/drv_csv.html - you can do:
ogr2ogr -s_srs EPSG:4326 -t_srs EPSG:...
12
votes
Accepted
Categorising point layer twice by size and form in QGIS
You can use data defined size override for this:
Click on the symbol in your categorized renderer:
Click on data defined override for size and choose the assistant:
Choose your source and load the ...
12
votes
Accepted
Adding CSV layer to QGIS when X and Y fields are the same
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:]
...
12
votes
Accepted
Counting fire occurences per county per year using QGIS
You can use the "Statistics by categories" from the Vector analysis toolbox in QGIS.
Select your layer, leave 'Field to calculate statistics on' empty, select "COUNTY_NM" and "...
11
votes
Python script to export .csv tables from GDB
A simpler solution would be to convert to dbf file format, in which case you you can use the out-of-the-box Table to Table (Conversion). This tool also allows you the freedom to select which fields ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
csv × 1237qgis × 539
shapefile × 152
arcpy × 109
import × 109
arcgis-desktop × 107
python × 107
attribute-joins × 74
export × 66
pyqgis × 64
coordinate-system × 62
convert × 58
arcmap × 51
coordinates × 50
point × 49
google-earth-engine × 45
attribute-table × 44
excel × 44
raster × 36
gdal × 34
polygon × 33
qgis-3 × 32
r × 29
ogr2ogr × 29
geojson × 24