Questions tagged [python]

Python is an open source interpreted programming language used in many GIS programs.

Filter by
Sorted by
Tagged with
0
votes
0answers
20 views

When calcuating distance between points on Earth why are my Haversine vs. Geodesic calculations wildy diverging?

I am getting wildly diverging distances using two approximations to calculate distance between points on Earth's surface. I am using the Haversine (vectorized) approximation (spherical earth) and the ...
2
votes
1answer
33 views

Listing attributes of arcpy.Describe object in python?

I am trying to create a json structure that will describe a multitude of different arcpy data types (FeatureClass, FeatureDataset, Workspace, etc). I would like the script to be dynamic and give all ...
0
votes
0answers
6 views

Export ALL selected raster layers in QGIS

I am working in QGIS 3.8.3 in Windows 10, I have to export all the selected raster layers, is there any way of doing this instead of exporting them one by one? I only would like to export all of ...
1
vote
0answers
22 views

Finding percentage of intersection in polygon

For two given polygons generated in this code, how do I find the percentage of intersection on the rectangle? [The polygon was created using the Alphashape function] (Linked to Finding points of ...
0
votes
0answers
10 views

Formatting widget value to avoid scientific notation

I have visualized a geodataframe using CARTOframes (v1.0b3). The map contains a formula widget that shows the count of the features displayed on the viewport. This is my code: Map(Layer(disagree_lgdf,...
1
vote
0answers
30 views

Finding points of intersection in polygon?

For two given polygons generated as shown below, how do I find the points that are intersected on the rectangle by the circle? [The polygon was created using the Alphashape function] (Similar to ...
1
vote
2answers
30 views

QGIS Python ImportError: No module named builtins

When I am executing a python script for doing a geoprocessing task using QGIS Desktop 3.8.3 (executed using a windows .bat file), I am getting an import error. from builtins import zip ImportError: ...
2
votes
0answers
36 views

Making meridians converge to both poles?

def transformx(lon, lat): x = lon*(90-lat)/90 y = lat return x, y What is the formula to make the meridians converge to both poles like the picture attached?
1
vote
1answer
35 views

Reference to raster list

I am writing my first Python plugin. There was a problem during work. The plugin is designed to select a raster and calculate the statistics for the area bounded by the vector. I have created a list ...
0
votes
0answers
16 views

SQL Queries using Python/PyQgis after connecting to database [on hold]

In QGIS I connected to a SQL database using MSSQL. I now want to read one (or more) tables from that database and extract some data. Any hints on how to do it?
1
vote
0answers
24 views

Python: distance of point to polygon border

I want to measure the distance of a point(lat,long) to a the border of a Polygon. So I have created the polygon with the coordinates. from shapely.geometry import Polygon, Point Polygon(zip(lon_list, ...
-2
votes
0answers
24 views

Get number of points in MultiLineString

How to get number of points in a MultiLineString using Shapely? intPoints = MultiLineString((372 130, 319. 109), (320 109, 300 101), (300 101, 150 40), (100 20, 92 17)) I want to perform this ...
0
votes
0answers
16 views

Python: Select x,y,z point below a DEM (DTM)

I have a DEM file and a big list of X,Y,Z point (about 1M). Each of them can be below or above the DEM file. Is the a quick way to select of the x,y,z points below the DEM file using python ? I did ...
0
votes
0answers
60 views

QGIS Python Error : No module named 'encodings'

I have written a python code which uses the 'Raster Surface Volume' algorithm of QGIS Desktop 3.8.3. When I execute the python code, I am getting an error : The system cannot find the path specified....
0
votes
0answers
22 views

Random Forest classification for satellite imagery in python [on hold]

I have a subset of an imagery data from triplesat satellite which I have labeled myself using polygons in SNAP. As I exprted my labeled subset, I got a tif file and a .data file including info of the ...
1
vote
1answer
58 views

QGIS plugin mouseClickEvent

I am writing a plugin which shows a graph in a qGraphicsView based on some selected points. I want to be able to read out points clicking in the graph, so I've written a mosePressEvent eventhandler ...
0
votes
1answer
26 views

Cropping GeoTIFF by lon and lat [on hold]

I am looking for a way to crop a raster by longitude and latitude. I am used to do this task with NetCDF but since I need to use GeoTIFFs in this case, I am struggling with the task. Loading a TIFF ...
0
votes
0answers
15 views

Legend of GeoDataFrame does not sort categorical data values

I try to plot a map of temperature with geopandas in Google Colaboratory. This is my dataset: id = '1LOywA8JPP6vOFDP-CBOBgkSmX7zv2pDc' downloaded = drive.CreateFile({'id':id}) downloaded....
-1
votes
0answers
33 views

Using gdal_rasterize gives ERROR 1

I'm trying to rasterize a single-band raster, the NDVI from sentinel 2 but I have problems with gdal_rasterize. gdalinfo -proj4 C:\Users\....\....\clip_NDVI.tif gdal_rasterize -a "id" -l myshapefile ...
0
votes
0answers
21 views

Snapping value = 0 in Qgis

I am building pipes network, I need check connection between of pipes. I want to pipes must snap and tolerance has value = 0. Is there any tool to check and fix this things. I know Topology Checker ...
2
votes
2answers
45 views

Reversing coordinates of MultiPoint using Shapely?

How to reverse the cooridnates order of this MultiPoint: MULTIPOINT (92 169, 100 163.552380952381, 105.2167832167832 160, 266.7552447552447 50, 290 34.17142857142857, 302 26) to this: MULTIPOINT (...
-2
votes
0answers
23 views

Writing function that receives coordinate pair and determines if its either projected or geographic [on hold]

from math import radians, cos, sin, asin, sqrt def cartesian_planar(metres): x_dist = xl - x2 y_dist = yl - y2 dist_sq = x_dist**2 + y_dist**2 distance = math.sqrt(dist_sq) return ...
2
votes
2answers
110 views

rasterio “invalid dtype: 'bool'”

I want to write a binary raster to disk. I have the numpy array whose dtype is: dtype('bool') I try to open a GTiff for writing: img_output = rasterio.open( "../../binary_output.tif", ...
1
vote
0answers
22 views

Layer failed to load using PyQGIS on macOS Mojave

The following is the code that I wrote with the help of PyQGIS Developer Cookbook from qgis.core import * from qgis.gui import * import os #Reference to QgsApplication qgs = QgsApplication([], False)...
2
votes
1answer
80 views

Getting elevation for multiple lat long coordinates in Python

I have seen the answer to Elevation info for multiple lat long coordinates and I would like to be able to do this with a python script instead. I cannot use Googles API because I have 8000 points. I ...
1
vote
0answers
39 views

Distance between centriod of the polygon and each and every point of the polygon [on hold]

I'm trying to calculate the distance between centriod of the polygon and each and every point of the polygon using GeoPandas Python I need to find the distance between centroid(18.9568383649 72....
1
vote
0answers
19 views

Get all road intersecting a polygon

I am trying to read from a local instance of the OpenStreetMap database all roads intersecting a boundary coming from another database. I actually get a result with the following piece of code: #...
0
votes
0answers
15 views

3D Display of sub map on a map with python [closed]

I have a map of heights represented by a numpy array (x,y, z = height), and a sub map of the first map, also represented by an numpy array. Is there a way to display a 3-dimensional representation of ...
0
votes
1answer
27 views

Writing shapefile of multiple geometry using Python [duplicate]

How to make a shapefile containing points, polygon, and line using python shapely or pyshp?
1
vote
1answer
34 views

Does ArcGIS Server 10.7.x always provide/support both Python 2.7 and 3.6, or sometimes the 2.7 one only?

Reading this ESRI support information from the Internet (select English language at the bottom of the page, other translations aren't always updated), it's not clear to me if a 10.7.x version of ...
1
vote
0answers
22 views

How remove a duplicated coordinate in multipoints using GeoPandas?

I have shapefile river data in line format, import this data with GeoPandas and apply it to a .boundary to get as initial and final coordinates of each line. But as lines intersect a coordinate may ...
0
votes
0answers
31 views

Landsat temporal images or scenes not overlapping each other [closed]

I am new to Landsat images. I am trying to gather temporal images of Landsat 7. First I downloaded images of same path and row for same place in different time stamp. I then then cropped a square ...
2
votes
2answers
51 views

Get field names in attribute table with Python

I have a geopackage file, with a layer called "MyLayer". Within this I have an attribute table with approx 20 attributes. I can read in each attribute individually like: import geopandas as gpd ...
2
votes
1answer
40 views

Calculating area of geometry using Geopandas? [duplicate]

Is there an easy way in geopandas to calcuate polygon areas after an intersection analysis? I am switching from ArcGIS to open source and try to translate my code. In ArcGIS I used: arcpy....
0
votes
1answer
25 views

Plot RGB using rasterio

When plotting and RGB image using rasterio, I have seen that it is necessary to normalize the values first (0-1) and the use show. I am using the following code for that: def norm(band): band_min,...
2
votes
1answer
45 views

OSGeo4W QGIS 3.8: don't understand setting of internal Path variable

As I understand it, when QGIS is started from qgis.bat some OSGeo4w specific folder paths are prepended to the OS PATH variable. When I do this and go look in Settings>Options>System>Current ...
0
votes
0answers
10 views

Enable Handler Class Methods to Yield Instance Attribute in Pyosmium

This question is regarding the package pyosmium specifically. I was just wondering if the following functionality is possible, and if not how it could be implemented. I want to stream/yield certain ...
0
votes
1answer
27 views

Mask rasterio raster with geopandas shapefile

I am loading a shapefile using geopandas as follows: import geopandas as gpd StudyA = gpd.read_file('.../Study_Area_Polygon.shp') Next, I am using folium to plot it interactively: m = folium.Map([...
0
votes
0answers
21 views

Classifying if a coordinate lies on a building

I'm trying to classify if a given coordinate (latitude, longitude) lies within a building footprint, street or elsewhere. To accomplish this task, I'm using OSM data and the Overpass API. I wrote the ...
0
votes
2answers
32 views

Importing ArcPy installed with ArcGIS Pro in PyCharm

I am trying to import arcpy in a script, which is running in a PyCharm environment using the Python 3.6.6 installation that comes bundled with ArcGIS Pro 2.3.2 as the base interpreter. I get the ...
0
votes
0answers
13 views

ogr2ogr SQL Expression Error, From starting with number

I'm merging shp files with ogr2ogr in a python loop and adding the specific filename as coloumn. A command looks like: ogr2ogr -f "esri shapefile" -update -append final/merged.shp 3044/...
0
votes
1answer
18 views

FeatureCollection is not a valid type of discriminator Error

I'm trying to pull in Planet data to visualise satellite imagery using Jupyter. I'm new to Python and I get an error like this: { "field": { "filter.config.0.config.type": [ { "message": "...
-1
votes
0answers
23 views

TypeError: can only concatenate list (not “str”) to list [closed]

I am new to learning Python. My code is as such. name="my name" name=name.split() yob=1997 cy=2019 age= cy-yob print(name + "is", age, "years old.") print(name [0][0] + "." + name[1][1]+". was born ...
0
votes
0answers
50 views

Using GDAL with Anaconda

I want to read sentinel-2's image (jp2 format) with anaconda: geopanda: for read shapefile folium (for create map in jupyter notebook ) (optional) gdal /osgeo : for read jp2 image I follow this ...
0
votes
1answer
27 views

How can I use GDAL in Python to Convert NetCDF to ASCII - and flip the latitudes?

I have a NetCDF file containing bathymetry. I am using the GDAL and NETCDF4 libraries to export the file to ESRI ASCII using the 'AAIGrid' format. However, a common problem is the latitudes are in the ...
1
vote
0answers
26 views

MMQGIS Geocoding Certificate Error

I am trying to geocode a couple of addresses, but I keep getting a "failure to connecting to API" error. I received my API key from signing up with Thunderforest, and I also installed certificates ...
0
votes
1answer
28 views

How to add a hosted Feature Layer from AGOL to my local ArcGIS Pro through Python?

I`m trying to find a way to add an online layer to my local map, through Python. I know how to grab the layer info, but don't know how to use it. onlinelayer = gis.content.search(mylayer)[0] itemid= ...
0
votes
2answers
28 views

Getting MemoryError from Fiona when merging large amounts of buffered data (Python)

I am using fiona and shapely together to buffer points and then merge them and write them to a shapefile. For almost all of my datasets, this is working fine. However, I am currently getting a ...
0
votes
3answers
52 views

Different NDVI in Python vs QGIS

When deriving NDVI out of a Sentinel-2 image - S2A_MSIL2A_20190502T074621_N0211_R135_T38SLF_20190502T102541 - I am getting a strange result when doing it in python vs in QGIS. In QGIS (using raster ...
1
vote
0answers
39 views

How to find shortest path by sea from startpoint a to endpoint b [closed]

Have implemented an algorithm which find a shortest path from start point [37.937187, 23.619259] to end point [-23.01231999999999, -43.134443000000005].. But array that I get as result is a path that ...