Hot answers tagged

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 ...
user avatar
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 ...
user avatar
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 = ...
user avatar
  • 1,493
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 ...
user avatar
  • 75k
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 '...
user avatar
  • 52.5k
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 ...
user avatar
  • 341
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 ...
user avatar
  • 75k
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 ...
user avatar
  • 52.5k
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 ...
user avatar
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. ...
user avatar
  • 72.4k
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. ...
user avatar
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.
user avatar
  • 82k
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 ...
user avatar
  • 63.7k
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 ...
user avatar
  • 141
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 ...
user avatar
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 = ...
user avatar
  • 1,614
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"...
user avatar
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"> ...
user avatar
  • 6,738
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 ...
user avatar
  • 72.4k
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 ...
user avatar
  • 36.3k
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 ...
user avatar
  • 3,479
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....
user avatar
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 ...
user avatar
  • 72.4k
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 ...
user avatar
  • 9,226
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 ...
user avatar
  • 8,217
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:...
user avatar
  • 51.9k
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 ...
user avatar
  • 25.5k
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:] ...
user avatar
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 "...
user avatar
  • 6,400
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 ...
user avatar
  • 50.3k

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