Questions tagged [python]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
20 views

gdal FlattenTo2D makes geom null

I have a df that has geoms as ogr geom in 3D. I was trying to convert to 2D but it empties out the geom. ipdb> df['default_geom'][0] <osgeo.ogr.Geometry; proxy of <Swig Object of ...
1
vote
1answer
68 views

Enabling tile caching for layer?

I published around 1000 layers in geoserver without enabling tile caching for layer. How to check a cache is enabled for a layer or not? How to enable tile caching (check box) for a layer under ...
2
votes
1answer
23 views

Sentinelsat: Error trying to download from Norweigan mirror colhub.met.no

I am trying to download the Sentinel 2 images over an area of Western Norway. Since the ESA archive is very slow, I am trying to use the Norwegian mirror for Sentinel instead (https://colhub.met.no/#/...
0
votes
1answer
26 views

clipping a vector layer with another vector layer using python

Sorry if this there is a really obvious solution to this question. I did not have any luck googling and looking at different books. I have an OSM vector layer that I want to clip with another vector ...
0
votes
1answer
25 views

Reprojecting data with GeoPandas using 'to_crs'?

I am trying to reproject a polygon so that it has the same projection than a raster dataset. raster.crs CRS({'proj': 'tmerc', 'lat_0': 0, 'lon_0': -183, 'k': 0.9996, 'x_0': 500000, 'y_0': 0, 'datum': ...
0
votes
0answers
27 views

Read contents of KML file into CSV format using Python (BeautifulSoup)

I have a KML file called Layers.KML which has multiple sub folders - Tree_Heights_Elevations, 20190516 - Chain Link Fence, 20190516 - Clearing Limits, 2016-0516 - Solar Array . ...
1
vote
1answer
37 views

AttributeError: 'NoneType' object has no attribute 'bounds'

I have the following geodataframes, corresponding to a regular grid: id grid_id geometry 0 48 0 (POLYGON ((2.052457758079306 41.42493869117656... 1 49 1 ...
1
vote
1answer
24 views

Method 'to_crs' to reproject with GeoPandas is missing

I am trying to reproject data using GeoPandas' to_crs method but it seems to be missing. When I type hasattr(gpd, 'to_crs') I get FALSE. Also, when I type dir(geopandas) in the command prompt it doesn'...
1
vote
2answers
36 views

How to calculate number of vertices in GeoPandas

Is there any method to count number of vertices of polygon (or multipolygon etc.) that is in 'geometry' column in datatable, but using GeoPandas? Example: Let's say I have polygon POLYGON ((552971....
1
vote
1answer
54 views

QGIS script for filling fields in attribute table

I want to write a script that will fill field values in the attribute table the following way: There are dots with attributes and lines I am creating. I want the script to use the field value of the ...
2
votes
0answers
18 views

Creating Swath View from Point data using Python?

My situation Input: point data from planting file Feature Attribute: [('DeletionFlag', 'C', 1, 0), ['Field', 'C', 254, 0], ['Dataset', 'C', 254, 0], ['Product', 'C', 254, 0], ['Obj__Id', 'N', 15,...
2
votes
0answers
20 views

QGIS dll load fail with from qgis._core import *

I have a error in console python, I tried using pyqgis without qgis interface. My problem is when I use: from qgis.core import * Console's the message is: from qgis.core import * Traceback (most ...
1
vote
0answers
47 views

How can I compute confusion matrix using Python [on hold]

My project is about "Extracting water and urban features from satellite images". I have extracted urban and water features using Python code. Now, I want to do accuracy assessment. I know two primary ...
11
votes
3answers
1k views

Histogram Matching using Python to improve mosaicking process of multiple overlapping rasters?

I am trying to do histogram matching using Python to improve the mosaicking process of multiple overlapping rasters. I am basing my code on that found at: http://www.idlcoyote.com/ip_tips/histomatch....
2
votes
1answer
36 views

arcpy.da.NumPyArrayToTable() RuntimeError: Unspecified error

Using arcpy for ArcGIS Desktop 10.7.1... In order to append data from a Pandas data frame to an ArcGIS table, I am attempting to create a temporary in-memory table from the Pandas data frame as ...
1
vote
1answer
32 views

Planet not able to get a response from quick-search API call

My question is related to: Planet API not being accepted for quick search but is on stats and planet quick-search api not recognizing authentication?. I am not able to successfully get a response ...
1
vote
0answers
26 views

All 0s result from raster calculator in python

Raster calculator is not working correctly for a single calculation using a standalone Python script. I am trying to add 1 to a pre-existing raster. It processes, but the resulting tiff file is all 0s....
0
votes
0answers
21 views

Visualizing queue length with colored Polylines - Folium

I have a bunch of PolyLines that i want to color code based on the length. I managed to change the color of the entire line, based on the length of a line segment (between 2 of 6 points), but I am ...
0
votes
1answer
29 views

Cannot access LibKML driver using OGR in Python

I am trying to read a kmz file using OGR in Python. I believe the standard driver for reading .kmz files is LibKML (Can ogr2ogr read .kmz files? How?), but I am only getting None when I am building ...
0
votes
1answer
33 views

Remove Cloud Cover with Python Earth Engine API

I am attempting to use google's cloudscore methodology to remove clouds from LANDSAT8 imagery. I am using python to do this. I can get this to work in java from the web code editor, but am unable to ...
-2
votes
1answer
13 views

run function multiple times [on hold]

i have a list: my_list[8000,8001,8002] function: def print_function(number): print(number) What do i want? I want to run the function multiple times, in this example 3 times with the numbers ...
2
votes
2answers
100 views

How to load the geometry field of a feature class to PostgreSQL?

I am trying to load a polygon feature class in a file geodatabse to a PostgreSQL table (extension PostGIS installed). This the process I'm following: I create table in PostgreSQL with required fields ...
2
votes
1answer
30 views

Unable to load geometry field from geodataframe to a PostgreSQL table 'geometry' field

I am trying to load a geodataframe to a PostgreSQL table, but I am struggling with the geometry field. First I read feature class using Geopandas: geodata = (r'path_to_gdb', driver='FileGDB', layer='...
1
vote
1answer
218 views

Unable to find either renderd.py or generate_tiles.py?

We created a Ubuntu 14.04.1 LTS x64 OSM tile server from packages using the excellent instructions provided by http://switch2osm.org/serving-tiles/building-a-tile-server-from-packages/ The tile ...
2
votes
2answers
155 views

PyQGIS (3.2) and H5PY DLL problem

I am working in a project in which I need to use PyQGIS and H5PY. The problem comes when I load qgis library and h5py, for example: import qgis import h5py I get this error: from ._conv import ...
0
votes
1answer
47 views

Geopandas intersects/contains fails between GeoDataFrames

I am struggling to make the GeoDataFrame functions: intersects/contains work between GeoDataFrames instances. Let t be a GeoDataFrame with contents: id ...
3
votes
1answer
61 views

Setting CRS : TypeError: 'NoneType' object is not callable [on hold]

I'm working with a naive geometry column imported from a csv file, like this: name geometry id 1 Abubilla (POLYGON ((424405.897979997 ...
23
votes
3answers
13k views

Transforming Shapely Polygon and MultiPolygon objects

Is there an easy way of transforming Shapely objects (namely, Polygons and MultiPolygons) from one projection to another without having to dig around and extract coordinates by hand? In fact, I don'...
2
votes
1answer
63 views

Creating equally spaced coordinates on California state map created with basemap?

I have created a California state map with basemap Python library and this shapefile. Code is below from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt fig, ax = plt.subplots(...
2
votes
2answers
408 views

How to get a Multipolygon object from Overpass QL?

I'm new to OSM/Overpass QL and there's a simple problem that I can't solve. I've been able to figure out the a query that will return the maritime boundary of a country. For example: (rel[boundary="...
6
votes
2answers
5k views

Split a large GeoTIFF into smaller regions with Python and GDAL [duplicate]

I have quite a large GeoTIFF-file (compressed 50MB but unpacked 6GB) and want to split it into several smaller regional files. I am using Python, and as I am a new GDAL user I do not really have an ...
3
votes
1answer
6k views

How to use ArcPy to copy selected features to an existing feature class?

Is there a way to copy a selected feature into an existing feature class? Sort of like append would do, but only the selected features. I want to iterate through a table and select features with a ...
5
votes
3answers
5k views

Generating random coordinates in multipolygon in Python?

How to generate random points in multi-polygon using geojson in python ? thus far I found a class in JavaScript named : randomPointsOnPolygon(numberOfPoints, polygon) but I need to use something ...
0
votes
1answer
42 views

Retrieving lat-lon coordinate from projdef?

I am trying to plot an hdf5 file where geographical domain is defined like : group LL_lat : 23.55908203125102 LL_lon : -138.4263916015652 LR_lat : 16....
3
votes
3answers
4k views

Read KML file with GDAL/OGR for Python

I have file : test.kml and I try to open it with GDAL/OGR (1.6) librairie in Python (2.5). But I don't succed can you help me ? This is my code : from osgeo import ogr adresse = 'test.kml' driver ...
2
votes
1answer
57 views

Getting EPSG code in pyproj with version==2.1.3?

I'm using pyproj in python and I want to get epsg code based on an existing Proj class. An example in version=1.9.6: from pyproj import Proj CGCS2000metre = Proj(init='EPSG:4544') print(CGCS2000metre....
1
vote
0answers
21 views

Opening EOS netCDF4/HDF5 file with correct format using xarray?

I am using xarray (version 0.12.2) to work with the MODIS/Terra+Aqua MAIAC Land Aerosol Optical Depth dataset (MCD19A2.006). xarray successfully opens that dataset with the correct variables and ...
1
vote
1answer
1k views

ValueError: array larger than output file, or offset off edge Python GDAL

I have been working on this iterator that would count instances where data conformed to a set of conditions over a number of rasters. I had people help me with other aspects of this script (Counting ...
1
vote
1answer
30 views

Error on Line 109 of Creating Random Points in Layer Bounds Tool

I am using the latest version of QGIS 3.6.3 and I am getting the same error regardless of what I do when trying to run the Create Random Points in Layer Bounds tool. Here is the error: QGIS version: ...
0
votes
0answers
36 views

Hacks to make Python scripts faster? [closed]

I've got a GDAL/OGR-based Python script that's drawing buffers around roads. In any particular area, it goes road by road (feature by feature) drawing a buffer around a road, and appends that road's ...
1
vote
0answers
10 views

Setting layer blending as additive with opacity in Kepler GL for Python

I'm using KeplerGL in python (in a Jupyter notebook) to plot polygons on a map with different layers. After setting the layers, I've tried to find where can I edit their opacity when adding them up, ...
2
votes
2answers
35 views

Creating new GRASS locations while looping in Python script

I am making a Python script for processing my data. import grass.script as grass import numpy as np def main(): f = open("D:\\Glaciers_selected.csv", 'r') fl = f.readlines() for x in ...
1
vote
0answers
20 views

Geopackage vector data type

I am reading a shapefile in Python using geopandas, join some tabular data and export to geopackage using geopandas. The entire process is very easy. However, when I export the vector data, the file ...
0
votes
0answers
42 views

Obtaining geographic coordinates of satellite images using Python? [closed]

Using a satellite image of a band it is possible to obtain the geographic coordinates and the value of the color in a matrix. I just obtained an array using GDAL but it just represents the colors of ...
0
votes
1answer
28 views

Finding overlapping areas between two or more GeoTIFF files

How can one programmatically understand overlapping areas between two or more GeoTIFF files captured at various timestamps for the same location?
4
votes
2answers
5k views

Create a polygon grid using with Geopandas

I'm working with a geodataframe of points and I need to create a grid of rectangular polygons. I know how to have bounds of the geodataframe with gdf.geometry.bounds. Now using this information and ...
0
votes
2answers
216 views

GDAL installation on MAC OSX via conda fails, linked due to Libpoppler and font configuration

When installing GDAL via Conda, install fails, on OSX Mojave and Python 3.7: dlopen(/Users/tomkom/anaconda3/lib/python3.7/site-packages/osgeo/_gdal.cpython-37m-darwin.so, 2): Library not loaded: @...
6
votes
2answers
584 views

Export a configured Atlas with a Python script / command line?

I just want to export a configured Atlas (composer with Atlas option and cover layer enabled) I tried this : composerView = qgis.utils.iface.activeComposers()[0] composition = composerView....
0
votes
0answers
24 views

Unsupervised classification using Python? [duplicate]

Is there a way to use unsupervised classification with satellite images to determine similar regions using python with gdal or with any library?
1
vote
1answer
78 views

Why is there a difference in length for two lines created from the same points, one with ArcGIS Pro and the other with Geopandas? [closed]

Update Question off-topic because I launched the ArcGIS treatment again and for an unknown reason this time I obtained the 21.56km length I was expecting. It means the error comes from either my ...