Tagged Questions
Python is an open source interpreted programming language used in many GIS programs.
0
votes
0answers
13 views
QGIS selecting features and using field calculator to update existing field using python
I am wondering how to select features based on conditions from multiple fields to update an existing field in QGIS.
This is the code I have so far. The expression I want to use to select features is ...
1
vote
2answers
33 views
GDAL version in QGIS
When calling GdalUtils.version(), the returned information is
"2010100"
While I can identify GDAL2, I´m unsure about the next version steps. It could be 2.1.1 or 2.0.1 or 2.1.1.
Currently, the ...
2
votes
3answers
42 views
Get individual pixel values on a raster image using gdal and python [duplicate]
I'm now stuck with writing a piece of code to look up individual pixel values on a raster image.
This piece of code mainly executes two tasks:
(1) converting world coordinates to raster coordinates (...
1
vote
0answers
10 views
Icon twice after reloaded plugin
I am making a QGIS plugin with QGIS 2.14.10
I use the reload plugin each time i want to update the plugin. But sometimes, when my plugin bug and i reload it, i get the icon twice in the toolbar and ...
2
votes
2answers
31 views
Conversion of a GeoJSON into EWKB format?
I see libraries such as shape from shapely.geometry that support conversion to WKB and WKT binaries. What I am unable to find is guidance on converting to EWKB specifically.
I suspect this is ...
1
vote
0answers
22 views
PYQGIS error in file format working in standalone script using PCharm
i want to run this PYQGIS python script in standalone out of QGIS and i use PyCharm Idle.
but my code have error on the file format.
the script
from qgis.core import *
import sys
import qgis.utils
...
0
votes
0answers
12 views
Using Python to add 1, 2, 3, etc to end of point feature attribute that falls within same polygon? [on hold]
The points are poles that fall within the same map number grid. The numbers that fall within the same grid have to be unique and require a 1,2,3,etc.
0
votes
1answer
26 views
Extract time series values from a 3D (lon,lat,time) NetCDF file using Python
I want to extract time series from a variable in a 3D (lon,lat,time) netcdf file at specific lon/lat points. The raster is a nc file where:
cell: 1.5°×1.5°
time step: 1 month
lat extension: (0.75,89....
1
vote
1answer
49 views
How to calculate pixel coordinates for each pixel in raster? EPSG 27700 (British national grid)
I have little knowledge of GIS.
I have some Met Office rain radar files (NIMROD binary files). These contain raster data where each pixel is a 1km grid square. I am trying to calculate the ...
1
vote
0answers
23 views
Problem with mapnik
My code:
import mapnik
geometries = [
(0, "POLYGON ((0 0, 5 0, 5 5, 0 5, 0 0))"),
(1, "POLYGON((1 5, 4 5, 4 6, 1 6, 1 5))")
]
ds = mapnik.MemoryDatasource()
ctx = mapnik.Context()
for ...
0
votes
0answers
23 views
Extracting name of Map document (MXD) from path with Python? [on hold]
I'm trying to get the MXD name from full path for a later use as a filename for a csv. So far I solved it by using the code below. but this won't be the way it should look like. Is there a better way ...
4
votes
1answer
84 views
Create a folder adding a record
Working in QGIS I have a point layer with ad attribute "NAME".
Is there any way to automatically create a folder called "NAME" where putting the attachments?
Maybe I could use something like this "How ...
0
votes
0answers
15 views
Editing rivers and country boundary in Basemap python module?
I am using the python Basemap module for maps generation. I wanted to edit the rivers and country boundary of the basemap defaults (drawcountries() and drawrivers()).
They are in .dat (eg. rivers_l....
0
votes
0answers
31 views
Resample point cloud data
I am working on point cloud data, but do not know how to re-sample the point cloud by equally spacing them vertically and horizontally. If possible in this direction can anyone via Python or ...
1
vote
0answers
22 views
QGIS Python Console AddMaplayer but with low resolution (very dim) [on hold]
Update: Figured. I used the wrong style file.
I'm new to QGIS Python develop. I was trying to add raster layer (.asc file) into QGIS. Below are my srcrips.
from qgis.PyQt.QtCore import *
import gdal
...
0
votes
0answers
30 views
How to sort an attribute table using qgis and python? [closed]
I want to sort a column of numbers in the attribute table programmatically and permanently with python in QGIS. Is this possible ?
-1
votes
0answers
15 views
Why is single road sometimes split into separate layers? [closed]
How did @watkipet calculate the road length for Why is a single road sometimes split into separate layers?
What I am facing is that for roads that have a 1 way up and a 1 way down, like an ...
1
vote
0answers
43 views
What is the fastest version of gdal2tiles?
I have multi-CPU linux server, so I wonder what is the fastest parallel version of gdal2tiles.py ?
My Ubuntu version:
lsb_release -a
Description: Ubuntu 12.04.5 LTS
How I install the package:
...
2
votes
0answers
23 views
Opening Sentinel 2 images with GDAL in Python
I'm trying to open Sentinel-2 images with python, and as far as I can tell, I have GDAL 2.1 installed, which (so I understand) ships with a Sentinel 2 driver. At least, the lines
from osgeo import ...
0
votes
0answers
30 views
Mosaic Raster Datasets using Rasterio or GDAL
I am currently experiencing a problem with the gdal_merge.py command to mosaic two raster datasets.
import subprocess
filea = 'E:\SAMPLE\test4_mosaicking_datasets\2016_02_07\...
-2
votes
0answers
42 views
Read informations from file and import in QGIS [closed]
I am new to programming but I want write QGIS plugin that read a "text" file (an HecRas .SDF with coordinate and other informations) and import that as Shapefile.
My problem is that the SDF file ...
-1
votes
0answers
27 views
Use gdalwarp in Python script [closed]
I am trying to use gdalwarp in a Python script for QGIS with the following line :
subprocess.call(["gdalwarp","crop_to_cutline", "-cutline "+ mask ,dem, output], shell=True)
But i have no result, ...
0
votes
0answers
24 views
Calculating Shape Indices using open source python libraries? [closed]
I'm creating an object / rule based classification using Python and I'm trying to calculate Shape Indices for the segments I have created. They are currently in a Raster Attribute Table, but could be ...
1
vote
1answer
22 views
How to map Albers projection raster in Basemap of python?
I confused the setting of Basemap about Alers projection. I want to plot a province area of Nation to pcolormesh. the value of lat_0 and lon_0 is Nation map's center longitude and latitude or this ...
1
vote
0answers
37 views
How can I get QGIS to work with my Python2.7 Anaconda Distribution
I use Python 2.7 from Anaconda installed in a python environment on my computer (MacOS Sierra 10.12). QGIS is installed from the KyngChaos framework, and I know that there are problems with mixing ...
6
votes
1answer
73 views
Convert shapefile from projected coordinates using python
Newbie here struggling with GIS. I am trying to map out wards for the city of Milwuakee using shapefiles found on their county website county website. I am following the thread here with some success. ...
2
votes
0answers
35 views
Installing Python plus ArcMap plus ArcGIS Pro plus GDAL?
My various installations of ArcMap, OSGeo4W and Python 2.7 (plus 3.4) are a mess. I've resorted to copying the entire Gdal directory (per version and processor) to the site-packages directory of all ...
1
vote
1answer
31 views
geopandas have a bug in sjoin?
i want to create a simple spatial join between points and polygons using geopandas but i thing so geopandas has bug ?
geopandas code :
from geopandas import gpd
import geopandas
points = ...
0
votes
0answers
29 views
add drop-down list in parameter input using script editor qgis 2.8 [duplicate]
in the script editor in qgis, when choosing string parameter type, a default value must be added according to https://docs.qgis.org/2.8/en/docs/user_manual/processing/scripts.html
What happen is that ...
2
votes
0answers
34 views
Efficient way to analyze multiple (large) rasters against a different raster using numpy
The situation I have run into involves four rasters. I will try to explain each one and what it is for to help you get a better idea of what I'm trying to achieve.
One of the rasters has been ...
0
votes
2answers
37 views
Spatial join using python shapely and fiona
I want to create a python script when count how many points(from point shapefile) is in the polygons(polygon shapefile) and I want that count to create a new polygon shapefiles with the polygons where ...
1
vote
1answer
55 views
How to create a small polygon vector layer from a larger layer efficiently in QGIS?
I am creating a plugin for QGIS in python which needs to load in parts of a larger polygon vector layer. This layer is taken from a shapefile and then a new smaller vector layer is created by adding ...
2
votes
1answer
26 views
How to get a list of supported gdal formats within python
Is there a way to get a list of installed gdal formats on a system with python? On the command line this can be done easily with:
gdalinfo --formats
...but can it be done in python?
2
votes
0answers
63 views
How to trigger qgis command from outside of qgis
Imagine you have a simple (maybe shared) EXCEL sheet lising your coordinates. For each coordinate you want to check a feature in a layer or arial imagery. To make it efficient, it would be perfect to "...
1
vote
1answer
25 views
Create GPS (gpx) routes from GeoPandas geodataframe
I have a GeoPandas geodataframe with LineString geometries and I'd like to export them into .gpx files as GPS routes.
I've searched for hints in the web but found anything useful.
Are there ...
2
votes
2answers
74 views
Saving a WFS layer directly to the disk using QGIS or PyQGIS?
I know how to properly load a layer in QGIS from a WFS service, but I would like to directly save it to a .shp file (without the preliminary loading of it into QGIS).
Is it possible to do this ...
3
votes
1answer
46 views
Python shapely difference between two polygons
I have a geometry question using shapely,Fiona and polygons shapefiles with big data(over 700000 features any polygon shapefile).
polygon1.difference(polygon2)
I want to find the difference between ...
1
vote
1answer
34 views
Create PostgreSQL function using python
I am creating trying to create a function inside PostgreSQL from python. My connection to PostgreSQL database uses psycopg2 and connects successfully in other instances. Code:
pg_cursor.execute('...
0
votes
1answer
31 views
Create routing graph (as software objects) from roads Shapefile using pgRouting
Intro: It's easy with OSM XML to run my software algorithm converting the XML to my custom software objects representing routing graph: You have ways with easy links to the (ordered) nodes ...
0
votes
0answers
17 views
How to find out Actual coordinate(pixel values) of chunk relative to the actual image?
I have an image of let say 500 X 500 px, I created tiles/chunks of size (10, 10). Now I want to find out actual chunk coordinate relative to the Original 500X500 px image.
Ex
I have first chunk of ...
3
votes
1answer
42 views
JSON rings data to PostGIS
Pulling data from a arcgis web query and using python/psycopg2 to insert it into postgreSQL. Here is one of the geometry attributes
js = json.dumps(i['geometry']['rings'])
this line prints
[[[...
1
vote
0answers
42 views
Python error clipping raster
I am trying to clip a raster with a vector layer mask (shapefile) using the clipper tool (gdal) but I've got the next error:
Traceback (most recent call last):
File "C:/PROGRA~1/QGIS2~1.18/...
1
vote
0answers
42 views
Running Python script in GRASS every time map extent is altered
I am looking to develop a python script that triggers every time the user zooms or pans to a new map extent. The script I have in mind will clip a raster to the visible extent thus reclassifying the ...
2
votes
1answer
35 views
Excluding nodata value in band calculation with Rasterio?
How do I exclude no data values when doing a raster calculation with rasterio. I realise that the files are read into an array, and that "0" is a nodata value. However, when I do a simple sum like "...
2
votes
1answer
53 views
Cutting a polygons into smaller squares in Python [closed]
In order to analize a GeoTif image we'd like to cut a huge polygon feature from a shp file into smaller chunks (this is because for some reason our analysis is not performed well with a polygon with a ...
4
votes
2answers
67 views
Using Rasterio or GDAL to stack multiple bands without using subprocess commands
Does anyone have a eloquent way of stacking multiple .tif files into a multiple band stack using Rasterio and/or GDAL?
I am looking for a way to avoid using a subprocess command like gdal_merge.py ...
3
votes
1answer
35 views
Attempting to run first script after setting up environment for QGIS and python?
I uninstalled arcmap and all existing python installations. Then I followed the instructions from https://www.youtube.com/watch?v=Chq9fTRKsHk&t=2s to install qgis and set the environment variables....
0
votes
1answer
26 views
Export selected feature/s to shapefile with open source python library
I need to be able to select one feature/record at a time within a polygon shapefile, regardless of how many shapes it contains, using open source python libraries (e.g., OGR, pyshp, fiona). Then I ...
0
votes
1answer
33 views
How to import QGIS layer to a Spatialite table
I have a Spatialite database with a table called spatialite_objects, with spatial and non-spatial data.
Another layer is an Oracle Spatial Layer (id, geom) with 2 table joins (based on 2 csv files) ...
1
vote
1answer
33 views
Building a plugin in Qgis for NDVI calculation using qt creater [closed]
I want to build a Qgis pluin using Qt designer. What elements will I add to the dialogue of plugin in Qt designer. Also I want a python script for that plugin which can manipulate the raster stacked ...