Questions tagged [python]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
33 views

Getting geometry column integer SRID from a GeoPandas geodataframe?

The primary answer to Adding GeoPandas Dataframe to PostGIS table? requires entering the geodataframe geometry column's integer SRID. Getting the CRS attribute using the crs attribute like so import ...
2
votes
2answers
36 views

Reducing a box while keeping its center?

So I have to draw a second box inside the original box but reduced by a factor. I have the first coordinates of the box and I have to calculate the new coordinates that would draw the new box. def ...
0
votes
0answers
13 views

Determine closest coordinates based on heading or COG [closed]

I have a ship route made of a set of lat/lng coordinate points. I want to know which is the ship next closest point given its course over ground or heading. I'm then going to use this point to ...
1
vote
1answer
31 views

Transform geospatial data from decimal degrees to x,y coordinates using pyproj in Python

I have the following dataframe latitude longitude xx yy 0 37.75153 -122.39447 553343.041098 4.178420e+06 1 37.75149 -122.39447 553343.069815 4.178415e+06 2 37.75149 -...
0
votes
1answer
26 views

Reading Sentinel2 ROI using GDAL and vsizip without downloading the whole image

I would like to read Sentinel2 data from remote using GDAL and /vsizip so to access just a portion (let's say a square of about few hundreds meters) of each image, from which extract and display just ...
1
vote
0answers
25 views

GDAL C# - ReWrite of PY function in C# to CHIP dataset

I am working on a small project that utilises GDAL and its C# bindings. TASK To chip a dataset given the top left and bottom right LAT/LNG coordinates. PROBLEM My resulting CHIP is offset by 40km ...
4
votes
2answers
155 views
+50

Earth Engine: Simplest way to move from EE image to array for use in sklearn?

I've produced a very large multiband image in EE with the goal of classifying it using the classifiers implemented in sklearn (the native ones implemented in EE don't provide enough flexibility for my ...
0
votes
1answer
21 views

Join dataset to geography in Carto (Python)

I'm subscribed to two datasets and one geography on Carto Data Observatory. How can I join them to each other using Python? I have converted both datasets and geography into pandas dataframe, then ...
0
votes
1answer
35 views

Are spatial queries possible using Python and cx_Oracle?

I am trying to execute a spatial query on an Oracle spatial table via python using the cx_Oracle package. I can make generic queries successfully, but when I try anything involving a geometry or ...
1
vote
1answer
46 views

Convert a SQL Server Geometry into PostGIS spatial data with Python and shapely

I'm trying to migrate spatial data from a SQL Server database to a PostGIS database with Python. I need this to be automated since its not just one table, but a lot tables in a lot of databases. I am ...
0
votes
1answer
48 views

Python surface plot in QGIS

I'm new in QGIS and I’m having some troubles. I have produced a surface plot in python and I would like to import it in QGIS but I don't know how do that, can anyone help me? P.S. I also have the ...
2
votes
1answer
19 views

Write output of multiple files to a directory after processing using gdal.Translate and glob.glob?

I want to convert the data type (Int32 to Float32) of all the tiff images in a directory 'F:\\prep\\input\\' and save/write the outputs to a new directory 'F:\\prep\\converted\\'. I have tried using ...
3
votes
1answer
32 views

Automated image enhancement in Python

I'm using Landsat 8 imagery in Python and want to make true color images that would look good in a publication. I have many images, so ideally this would be an automated process where each image comes ...
-1
votes
3answers
79 views

ArcPy iterative workflow

I may just not know the terminology needed to find the proper google results but I am trying to count the number of feature classes and store that for reference later in the script so that if the ...
1
vote
0answers
21 views

Create .lyr file from open .mxd layer without removing layer

I have a tool that is meant to clip and reproject every layer in an open .mxd, and then create a new feature class and .lyr file with original symbology from the result, not adding either to the .mxd. ...
-2
votes
0answers
36 views

Application for LIDAR data [closed]

I'm looking for a Python or MATLAB program to separate or classify every horizontal line generated by a LIDAR (Velodyne HDL-64E). I want to know if this code is already existing, or some library for ...
2
votes
1answer
71 views
+50

Hillshade function calculation: ValueError: Received a NULL pointer

I'm trying to get a raster from a DSM running the following code from python libraries osgeo-gdal in python qgis console: import pandas as pd from osgeo import gdal df = pd.read_csv(azimut_altitude....
3
votes
0answers
35 views

OSError - cannot import geopandas

While trying to import geopandas error occurs: Exception has occurred: OSError Could not find lib geos_c.dll or load any of its variants []. I downloaded GDAL and fiona for Python 3.7 from this ...
1
vote
2answers
41 views

Removing both sets of duplicate points

I'm trying to create points on the edges of polygons. So far I have converted the polygons to lines, then exploded the lines, then ran the following code which plots a point in the middle of the ...
0
votes
1answer
30 views

PyQGIS Script failing to project layer to EPSG:54002

I'm trying to write a Python script to convert a vector layer using 4326 to EPSG:54002 World Equidistant Cylindrical for road distance calculations, but the script fails to do the conversion, I've ...
0
votes
0answers
12 views

Clip raster with PostGIS polygon layer using Python

I have two layers in the same SRID: single-band georeferenced raster in a TIF file single multipolygon in PostGIS I need to convert the pixels of the raster within the polygon into points (at the ...
0
votes
2answers
43 views

Google Earth Engine with Folium and Sentinel-1 Plotting

I'm attempting to plot Google Earth Engine Sentinel-1 SAR data in a Jupyter notebook with Python and Folium. To do this I'm trying to combine two pieces of documentation: EE Python Install -> Map ...
2
votes
0answers
16 views

What does “TGM” vs “TKG” mean from Sentinel 2 Images (Google Earth Engine)?

I extracted sentinel 2 images from Google Earth Engine using the Python API with something like this: # Sentinel 2 Image Collection s2_image_collection = ee.ImageCollection("COPERNICUS/S2_SR") ...
1
vote
1answer
42 views

How to exclude/eliminate invalid areas (such as NoData, cloud, water, etc) from raster so that it does not effect the accuracy assessment?

I have two classified raster (snow cover % 10-100) one is prepared from coarse resolution and another is from finer resolution. I am doing accuracy assessment and matrix calculation of snow cover %. ...
1
vote
1answer
49 views

Finding nearest points to an interpolated point along a Shapely linestring

I'm using Shapely to interpolate points every 500m along a linestring. For each interpolated point I'd like to find the nearest original points (immediately before and after) in the linestring. (I'd ...
1
vote
1answer
31 views

Combine multiple polygons into a single one (with holes)

I have the following GeoDataFrame with multiple polygons which represents a single area (raster_val = 1.0) with holes in the middle (raster_val = NaN): geometry ...
0
votes
1answer
29 views

How can I modify a VRTRasterBand sub-class,etc from Python?

I am using GDAL to merge a series of overlapping rasters using Pixel Functions to combine the color bands. As a proof-of-concept, my approach has been to create a VRT, and then to modify it in a text ...
0
votes
0answers
16 views

Carto, Checking the status of a layer calculation using API

I wrote a python script that updates the values in a dataset and then returns a static image of the map it's connected to. The problem is if I download the image too soon after updating the dataset, ...
1
vote
0answers
24 views

Handling Nodata values in sklearn (working w pyimpute)

I'm using sklearn for a classification project. Because I'm relatively new to doing geospatial tasks outside of a GUI, I'm using Matt Perry's pyimpute (link has all the code for that module) to handle ...
2
votes
2answers
81 views

QComboBox multiple selection - PyQT5

I'm making the gui for my QGIS3 plugin using PyQT5 and QT designer. I have a very long list of items in a QComboBox and I need the user to be able to select one or more items. I know that QComboBox ...
1
vote
0answers
17 views

OSMNx Extracting blocks from point and save coordinates of corners of each block

I am playing with OSMNx and I would like to extract street blocks, I have this code which should display the blocks import osmnx as ox import geopandas as gpd import shapely from shapely.geometry ...
0
votes
1answer
37 views

Warning1: TIFFReadDirectory:Sum of Photometric type-related color channels

I am reading and writing rasters using gdal and keep running into the error: Warning 1: TIFFReadDirectory:Sum of Photometric type-related color channels and ExtraSamples doesn't match ...
1
vote
0answers
38 views

Iterating using ZipFile on a folder

I'm trying to extract multiple shapefiles from a folder, all these shapefiles are zipped and some of them have subfolders under those zips (most of them have shapefiles right under the zip structure) ...
0
votes
0answers
40 views

Why is my PYTHONPATH setting itself to QGIS?

I'm trying to cleanup Python on my Mac. I keep getting this message in Terminal: Your PYTHONPATH points to a site-packages dir for Python 3.x but you are running Python 2.x! PYTHONPATH is ...
2
votes
1answer
41 views

Place a special function or action with QGIS

I use QGIS and want to place an option that when pressed, I perform a filtering without the need to enter commands. I am currently using the program to carry out an electricity project, where a ...
1
vote
1answer
30 views

BuildOverviews() not supported for VRT dataset

I am trying to build overviews in a VRT dataset with python GDAL. I try this code: out_vrt = os.path.join(out_dir, 'mosaic.vrt') ds = gdal.BuildVRT(out_vrt, [raster1.tif, raster2.tif]) factors = [...
1
vote
1answer
34 views

Check if shapefile Polygon has a valid number of points - Python [closed]

I'm trying to create a polygon from ShapefileReader.shapes() object in python using the shapely.wkt library. But I'm having the followeing error: IllegalArgumentException: Invalid number of points in ...
2
votes
0answers
70 views
+50

Find spatial and temporal variability from a GeoPandas dataframe of polygons

I have a geopandas dataframe of polygons (all rectangles ~100mx120m) and each of these polygons has an attribute for time and % ice coverage. This is all derived from imagery I collected in the ...
0
votes
0answers
16 views

It is possible to create Dashboards on AGOL using Python? Using (content.add) does not work

I am using Python to create AGOL maps, using a certain JSON template for it. It works perfectly, so I tried to apply it to Dashboards. However I have no success doing it, despite apparently both items ...
1
vote
1answer
43 views

How can I get the points where two line shapefiles intersect?

I have two shapefiles that I want to compare and get the points where they cross. I would like to avoid opening QGIS or GRASS since I am trying to automate a process so I have been looking at OGR, ...
0
votes
1answer
27 views

Resample raster from one resolution to another with GDAL Python API

i have some trouble warping one raster to different resolution. My input is a one channel tiff with. I know the geo-coordinates of x_min and y_max. I also know that the pixel resolution is 5 meters. I ...
1
vote
1answer
58 views

Getting date of creation for feature using osm_id [closed]

I have download some OpenStreetMap data from Geofabrik GmbH. https://download.geofabrik.de/asia/india.html I need to extract when was the first time each feature was created. E.g., for OSM_ID = ...
1
vote
1answer
69 views

Maximo Spatial: Convert UTM to lat/long with Python 2.7.0 (using only the standard Python library) [closed]

Maximo Spatial is a work order management system in which I can write scripts in Python 2.7.0. I want to write a Python 2.7.0 script in Maximo that will convert UTM coordinates to latitude/longitude ...
0
votes
1answer
25 views

Clip vector by extent in fiona [closed]

I'm relatively new to fiona and I'm wondering how I can crop/clip a vector file with a bounding box. It is important to mention I want to clip, not only to get the features withing the bounding box. ...
3
votes
1answer
41 views

Standalone QGIS App keeps crashing. Issue with Context or Threads?

I'm trying to setup an application for my company, that generates a PDF file for specific user generated coordinates: The user enters an address into the frontend (Flask generated), which is ...
1
vote
1answer
19 views

Specify a fields datatype while creating a new field in geodataframe with expression?

I would like to know how to set the field type of ['denominator'] in a geodataframe manually in this expression to "String": geo_df['denominator'] = df[["basalareap","basalareas","basalaread"]].sum(...
1
vote
2answers
21 views

gdalbuildvrt.exe doesn't recognize existing path

I used this function before but it suddenly stopped working on some updates. The simple command throws an error. PS C:\> c:\ProgramData\Anaconda3\Library\bin\gdalbuildvrt.exe 'c:/tmp/index.vrt' 'c:...
2
votes
0answers
29 views

Atlas export using Python: AttributeError: 'NoneType' object has no attribute 'atlas'

I'm trying to export my atlas layout named "Atlas_png", but are getting the error: AttributeError: 'NoneType' object has no attribute 'atlas' (line 27). I have tried to use this examples: Exporting ...
2
votes
1answer
58 views

Integrate sidebar with Python generated Leaflet map?

I have this map: link It was generated through Python code, not via JS directly. I want to add the Leaflet sidebar plugin within it, but it doesn't seem to work. As you can see in the github repo ...
0
votes
2answers
48 views

Given list of points (lat, long), how to find all points within radius of a given point [closed]

It's my first time working with GIS. I really wish I could share some code, but I don't even know how and where to begin. I have a Pandas dataframe with around 10,000 records. Each of them have a ...