Hot answers tagged

41

In the newer versions of QGIS (2.18+) there was a feature implemented to import .dwg-files into geopackages (.gpkg). This feature can be found under: Project >> DWG/DXF-import In order to make it work, you can follow those steps: Create a new/load an existing Geopackage with a fitting CRS Import DWG-file Check 'Expand block references' and 'Use curves' ...


23

You can use PostGIS's ST_GeomFromGeoJSON to bring in just the geometry part of the GeoJSON. Better yet, you can use ogr2ogr to import the entire JSON document: ogr2ogr -f "PostgreSQL" PG:"dbname=my_database user=postgres" "source_data.json" -nln destination_table -append (I haven't tested this with your data, add a comment if you have issues.)


16

Use the -nlt option. In this case you want: -nlt MULTILINESTRING There is also PROMOTE_TO_MULTI (GDAL 1.10 and later), which chooses either MULTILINESTRING or MULTIPOLYGON depending on the input layer. The use case for this is "doing a mass conversion of shapefiles that [mix] different types of geometries".


16

To expand on David Bitner's answer, here's an example ogr2ogr instruction demonstrating an optional OGR SQL clause to rename fields from a source dataset (shapefile in this case) before they are brought into a target dataset (a PostGREsql table): ogr2ogr -f "PostGreSQL" PG:"host=127.0.0.1 user=YourUser dbname=YourDB password=YourPass" "E:\path\to\...


15

tl;dr import qgis import PyQt4 etc is the correct way Long version Yes the import order can matter and in the case of QGIS 2.0 and above it does matter. You should always import qgis.core or qgis.gui, even just import qgis is enough, before you import any PyQt stuff. That seems silly. Why? In QGIS 2.0 we switched to using version 2 bindings of SIP ...


14

ERROR: **function addGeometrycolumn**(unknown, unknown, unknown, unknown,unknown, integer) does not exist It seems that PostGIS is not yet installed. PostGIS is an extension of Postgres which allows the use of geographic files. Install it and your import will work fine.


14

You can often make a WKT (Well Known Text) column in Excel without too much fiddling, which effectively creates a spatial definition for points, lines or polygons within a single field. What you want to do is create a WKT string, in the format: POLYGON((X1 Y1, X2 Y2, X3 Y3, X4 Y4, X1 Y1)) You can create new columns in Excel with the below formulas. The ...


12

I've been working with MS Sql Server Spatial since the '07 Katmai betas and I know of no Microsoft tool to do this. I had discussions with MS staff in '07 or '08 and at that point both reprojection and shapefile support were features they had chosen to leave up to third parties to implement.


12

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 csv file is comma-separated The longitude/latitude field names are "x" and "y" respectively The CRS of the loaded layers will be in EPSG:4326 But you can edit ...


12

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 are in geographic, which means using WGS84 is suitable for the given coordinates. Here is an image showing the correct location in Google Earth:


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(&...


11

From Settings >> Data Sources >> Data source handling, you may try to uncheck the Ignore shapefile encoding declaration option. If you move the mouse cursor over the above option, this message appears: Disable OGR on-the-fly conversion from declared encoding to UTF-8


10

To follow theJones and user5584, PyCharm 4 now stores the setting under "Project Interpreter" rather than "Python Interpreters." With all projects closed, and PyCharm still open, go to "Configure" and then "Settings". "Project Interpreter" is under the "Default Project" menu on the left. Click the settings gear in the upper-right, and then "Add Local." ...


10

If you go to the menu "Layer" and then "Add delimited text Layer", choose the correct delimiter (tabs, commas, semicolons, ...) and then choose the correct X and Y fields below it should show a preview at the bottom of the window - with all columns from the original file (see below). If you press "ok" a temporary point layer will be created. Each column ...


10

No idea what happened with the first three lines but the other lines are coordinates in UTM zone 28N. data_lat is X, data_lon is Y. I noticed that simply plotting each pair as X and Y points looked very similar, so I gave it a try on http://projfinder.com with success.


10

QGIS uses OGR in the background, and OGR interprets all columns as strings. The OGR CSV driver returns all attribute columns as string data types if no field type information file (with .csvt extension) is available. Using CSVT file with the same name as the CSV file allows you to specify types of columns in a CSV file. Limited type recognition can be ...


10

Your data is obviously in decimal degree, hence WGS 84 - EPSG 4326 is the correct CRS. In the import window change from 25832 to 4326 and you're fine.


10

Try to use EPSG:4326-WGS 84 as "Geometry CRS". And check the points are on the right location. If EPSG:4326 doesn't exist in the drop down list, then click the button near the drop down list and type 4326 to Filter box and select WGS84 EPSG:4326 from the list.


9

I hope, you got an answer before, but anyways: Modules -> Import/Export - GDAL/OGR -> Import Raster HTH,


9

There is an option in GDAL to rasterize polygons based on their attribute. But as far as I know it can not be string. But you can just add an attribute to your features and then give each feature a unique id. Let's say we call this field ID. Open your shapefile source_ds = ogr.Open("Longhurst_world_v4_2010.shp") source_layer = source_ds.GetLayer() ...


9

I imported a Planet File on a 24Gb Machine (Ubuntu Trusty) with the following .. bzcat planet-latest.osm.bz2 | osm2pgsql --verbose -U YourUser --flat-nodes flat-nodes --keep-coastlines --cache 24000 --hstore --hstore-add-index --tablespace-index pg_default --exclude-invalid-polygon --number-processes 6 --unlogged --cache-strategy dense --extra-attributes -...


9

I had the same problem (Arcmap would not import my csv file with headers, instead it would show Field1, Field2, Field3 etc). When I examined the file headers in Excel, I found...decimals numbers, spaces, percent signs etc. After replacing all of that with underscores or text, I had no problems. I dragged the .csv file into arcmap, opened the attribute ...


9

I had the same problem of QGIS reading a CSV file (saved from MS Excel 2011 on my Mac) as a single row. So, I re-saved the Excel worksheet as "Windows Comma Separated (.csv)" and QGIS was able to read it just fine.


9

You can convert your .img files to .tif using gdal_translate. Here is a shell script to convert all .img in actual folder to .tif #! /bin/bash for i in *.img; do gdal_translate $i ${i%.*}.tif done After this you can build .vrt gdalbuildvrt all.vrt *.tif Depending on the size of your rasters, you had better to build pyramids for faster rendering: for ...


8

You will need to do some formatting of your data to make them into polygons. Merely labeling a field as WKT will not help. If you have a lot of files (which it sounds like you do), the most effective way will be to automate your solution by writing a script. I was going to explain how when I decided that the simplest way would be to write an example script ...


8

You can open directly the asc file in QGIS (Add Raster File): After that the asc file appears gray: But if you choose pseudo-colors in the styles (properties of the layer) The result is


8

Install OpenJUMP and study what all has been gathered into it I have never really understood what all the alternatives are. ImageIO-ext is probably utilising native GDAL binaries if such are available but at least most other alternatives are pure java. There is also one more alternative in OpenJUMP called "Sextante raster" which is also pure java. Different ...


8

Sounds like you already successfully added your script to the toolbox, so you're close. You just need to set the parameters that are listed in the script within ArcMap if you want to run the script as a tool. In your catalog, right click on your script tool that you created and click on properties. You need to define your parameters under the parameters ...


8

You can do it using python. Add your excel to ArcMap, modify the #-lines and then execute code below in the Python window. Im using the Regular expressions (re) module to find the float part (for example 2.1) of each coordinate and a Dictionary to translate W to -1, E to 1 and so on. import arcpy, re temp = r'in_memory\excel' outlayer = 'out_lyr' sp = ...


8

Your problem is that, that is not a CSV file - which is a series of features one per row. What you have is more like an ASCII grid file, so with some editing you might be able to import it that way. You need to create a header block: ncols 4 nrows 6 xllcorner 0.0 yllcorner 0.0 cellsize 0.25 NODATA_value -9999 where you can fill ...


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