As of May 31, 2023, we have updated our Code of Conduct.

Hot answers tagged

28 votes

Creating sectors for telecom towers

Telecom cell site plan and optimization using QGIS Create Points or Site Locations: Create database in CSV (make sure antenna sizes are sorted in descending order: highest first to lowest last, such ...
Vamsi Krishna Uppala's user avatar
11 votes
Accepted

Seeking open source solution to access rasters in File Geodatabase?

I've just released a prototype program Arc Raster Rescue which extracts raster data from the ArcGIS File Geodatabase format.
Richard's user avatar
  • 1,801
7 votes
Accepted

Sample for MS Visual Studio C++ using GDAL library

Here's just the nuts-and-bolts from some working code: #include "gdal_priv.h" #include "gdal_alg.h" // in main()... GDALAllRegister(); // register all drivers // open your raster - format doesn't ...
Michael Stimson's user avatar
7 votes
Accepted

Calculate bearing between two decimal GPS coordinates (Arduino / C++)

You can calculate your bearing with this function. float bearing(float lat,float lon,float lat2,float lon2){ float teta1 = radians(lat); float teta2 = radians(lat2); float delta1 = ...
Mario Alzate's user avatar
7 votes

Improving QGIS source code efficiency?

There's no inefficiency here. They are only c++ pointers to the same layer instance -- it's not two instances in separate memory of the same map layer.
ndawson's user avatar
  • 27.1k
7 votes
Accepted

Seeking code behind Fix Geometries tool in QGIS

The code is in GitHub. The Fix Geometries tool is a wrapper to the function LWGEOM_GEOS_makeValid, which then calls different functions for different geometry types. You can read the various ...
JGH's user avatar
  • 38.3k
6 votes

GDAL Truncating/Normalizing Field names

Esri shapefile fields are limited to 10 characters, no matter how they are created.
Michael B's user avatar
  • 777
6 votes

Converting latitude, longitude (EPSG:4326) into EPSG:3857?

from pyproj import Proj, transform P3857 = Proj(init='epsg:3857') P4326 = Proj(init='epsg:4326') x,y = transform(P4326, P3857, lon, lat)
Marcel Wilson's user avatar
6 votes
Accepted

Determining if a group in legend is selected, using PyQGIS

You can use QgsLayerTreeView (accessible from the iface object) for that. I didn't find a direct way (QgsLayerTreeGroup doesn't seem to have a method for that), but you can simply reuse the following ...
Germán Carrillo's user avatar
6 votes
Accepted

Set Metadata domain with GDAL (python bindings)

You can do this by passing a dict: ds.SetMetadata({"X_BAND": "1" }, "GEOLOCATION")
user2856's user avatar
  • 59.9k
5 votes

Open QGIS project files in exclusive mode / alert if project file already in use

Took me a while to find: a long while ago I had a naive lock file implementation in place, using Python Macros (activate and alter in <QGIS>|Project|Properties...|Macros). I updated the code to ...
geozelot's user avatar
  • 28k
5 votes
Accepted

How to get coordinate system info from shapefile using GDAL/OGR?

Is there a different mechanism for vector files? Yes. Although the vector and raster drivers were merged in GDAL 2x, you still need to know which methods apply to rasters and which are for vectors. ...
user2856's user avatar
  • 59.9k
5 votes
Accepted

Existing C++ libraries that convert ESRI shapefile to DXF/DWG

GDAL supports open ESRI Shapefile and save it as DXF. The C++ API intro is here: https://gdal.org/ogr_apitut.html
Dmitry Baryshnikov's user avatar
4 votes

Converting latitude, longitude (EPSG:4326) into EPSG:3857?

This code snippet is C# and using an array called vertex to hold [x, y] double smRadius = 6378136.98; double smRange = smRadius * Math.PI * 2.0; double smLonToX = smRange / 360.0; double ...
Russell at ISC's user avatar
4 votes
Accepted

Is it possible to change the geometry without startEditing the layer

Data Provider vs Vector Layer A vector layer has a data provider which (normally [1]) is used to store data persistently. If you edit something on the layer with a normal edit session, your changes ...
Matthias Kuhn's user avatar
4 votes
Accepted

is it possible programmatically to rotate a svg of the feature without rotate all feature

In QGIS styling is layer based, so it is generally not possible to set different styles or different symbols for individual features. I think this is because features are handled by the data source, ...
Redoute's user avatar
  • 2,040
4 votes
Accepted

QGIS CPP multi-platform plugin deployment

It's generally discouraged to write c++ QGIS plugins, for the following reasons: They can't be distributed via the plugin library (only python plugins with no binary dependencies are accepted) The c++...
ndawson's user avatar
  • 27.1k
4 votes

Seeking C++ api to read/write PostGIS?

libpq allows us to connect to Postgres/postgis for read write operations. If you have installed Postgres,libpq is already available.It would be available at installation path like C:\Program Files\...
addcolor's user avatar
  • 1,232
4 votes

Understanding how `gdalwarp` works under the hood

GeoTransform is an array that contains six numbers: X origin Pixel width Angle (with vertical axis) Y origin Pixel height Angle (with horizontal axis) X and Y are coordinates of the top left corner ...
dmh126's user avatar
  • 6,542
4 votes
Accepted

Why does GDAL open a DTED file as a vector format?

You can use GetRasterCount() to test if the dataset is raster and GetLayerCount() for vector. http://osgeo-org.1560.x6.nabble.com/Discover-whether-a-GDALDataset-is-raster-or-vector-td5270223.html ...
user2856's user avatar
  • 59.9k
4 votes

How to get long, lat and altitude info from geotiff file using GDAL and C++

I'm not sure what you mean by "for each pixel". look at the raster API tutorial: http://gdal.org/gdal_tutorial.html. specifically look at the section "Getting Dataset Information". do you want to get ...
Reilly's user avatar
  • 306
4 votes
Accepted

Understand QgsRuleBasedLabeling

Rule keys and provider IDs are equivalent. The issue in your code is that you clone the root rule (rl->rootRule()->clone()) and so the new tree of rules gets new rule keys (=provider IDs). I ...
Martin Dobias's user avatar
3 votes
Accepted

Using GDAL/C++ to calculate distance in meters

GDAL depends on Proj.4 and the latest version of Proj.4 (4.9.1) includes an API for geodesic calculations (and the geod command uses this API). This is a translation of the C++ geodesic routines in ...
cffk's user avatar
  • 3,176
3 votes
Accepted

Rendering of SVG for layer symbols using QGIS?

Here is the solution,I finally understand why In fact a defaultSymbol is been created when I instanciate newsymbol , so instead of do an appendSymbolLayer I had to delete the default symbolLayer first ...
ainardi's user avatar
  • 843
3 votes

C++ code and ArcGIS Button

For creating the button, you should look at the following documentation: https://github.com/Esri/developer-support/tree/master/arcobjects-c++/create-command-atl As for the other parts, I am unable ...
Alexander N.'s user avatar
3 votes
Accepted

Building error on enum of the QgsMapToolIentfy Class

You have to specify the parent class name of the enum when using it outside its scope. lResultList = mIdentify->identify(lCoord.x(),lCoord.y(), QgsMapToolIdentify::TopDownStopAtFirst, ...
Matthias Kuhn's user avatar
3 votes
Accepted

Fastest way to process OSM

Osmium is a very fast and flexible C++ library for working with OSM data: http://osmcode.org/libosmium/ It supports all types of osm entities such as nodes, ways, relations and even historical osm ...
zehpunktbarron's user avatar
3 votes
Accepted

How to reuse memory pointer of GDAL Memory driver

The issue was resolved in the gdal-dev mailing list, here's how: create the MEM driver and create the mem image with 0 bands Get the pointer to your allocated memory with CPLPrintPointer Use AddBand ...
quimnuss's user avatar
  • 193

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