New answers tagged

0 votes

Adding RGB values to Laspy synthetic point generation?

Addon to this question. let say if I have X,Y,Z,R,G,B values and I take R,G,B values and calculated the average. Now the point cloud becomes X, Y, Z, AvgRGB. If I now want to see the plot using the ...
user avatar
  • 1
0 votes

plt.title not displaying

I believe the problem is that the plt.title() method is for an axes object (one of your two graphs while the plt.suptitle() method is for the overall 'figure' object. If you want a subtitle of sorts ...
user avatar
  • 433
1 vote

How to geocode the polygon of a street, instead of just a point

Google Geocoder doesn't seem to support returning precise polygons. But it does return an approximate bounding box (see https://developers.google.com/maps/documentation/geocoding/requests-geocoding#...
user avatar
0 votes

Pyproj Invalid projection: +init=epsg:25832

I believe your pyproj is referencing an incorrect crs data directory (see this error in the pyproj doc's). This has happened to me when switching kernels in Jupyter notebook/lab or in VSCode and the ...
user avatar
0 votes

GeoPandas/Geoplot losing first row when reprojecting

I was having the same issue. Disconnecting from my companies VPN fixed it. Perhaps the firewall was interfering with pulling info from the web.
user avatar
1 vote

How do you flip/invert/reverse the order of the coordinates of shapely geometries?

The substring operation in Shapely can be used for this. From the substring docs: If the start distance is actually past the end distance, then the reversed substring is returned such that the start ...
user avatar
  • 221
1 vote

How to convert crs_wkt starting with GEOGCRS to a ogc_wkt string (to use rioxarray.reproject_match)

Looks like "Pole rotation (netCDF CF convention)" was added in PROJ 8.2: https://github.com/OSGeo/PROJ/pull/2835 https://github.com/pyproj4/pyproj/issues/948 Requires PROJ >= 8.2 to ...
user avatar
  • 5,632
1 vote

Seeking Python module to find volume of xyz data

There are a few algorithms in QGIS that might be able to help you. I don't understand what you want to achieve, but the following algorithm might help you: # first, set the name of your raster/TIFF ...
user avatar
0 votes

Converting a NetCDF with multiple variables to GeoTIFF calling GDAL_TRANSLATE function from Python

Using vrt is one solution for sure. Apparently it worked like that for the votemper layer only: #old_name = file name with path etc. , var_name = subdataset prefix name #the prints are just for quick ...
user avatar
2 votes
Accepted

How can I activate GeoTIFF compression in QGIS 3.x gdal_translate?

Try 'OPTIONS':'COMPRESS=JPEG|JPEG_QUALITY=60' I executed the tool manually in QGIS, pressed Ctrl+Alt+H to see the command syntax:
user avatar
  • 51.2k
0 votes

'NoneType' object has no attribute

I'd say make sure all the files that are associated with that shapefile (.cpg, .dbf, .prj, .sbn, .sbx, .shp, .shx) are all found in the same file folder.
user avatar
  • 1
1 vote

Increase map size with subplots and Cartopy

I can't execute your code due to lack of data so here's a general example on how you could do it (using an explicit GridSpec instead of plt.subplots: in order to add a colorbar for each individual ...
user avatar
  • 271
1 vote
Accepted

Why is h3.polyfill(geojson, 15) returning empty list for this polygon?

You need to use h3.polyfill_geojson(geojson, 15) or h3.polyfill(geojson, 15, geo_json_conformant=True)
user avatar
0 votes

Creating a linestring from points using shapely

As you can see here, the error message is an old problem, and you can fix it by changing the order of the import process like this: import shapely from shapely import speedups from shapely import ...
user avatar
0 votes

Python ImportError with libgdal, undefined symbol: opj_codec_set_threads

To spell this out a bit more, opj_codec_set_threads was introduced in OpenJPEG version 2.3.0, and the above error is due to an older version of this library.
user avatar
  • 1
2 votes
Accepted

Why do rioxarray reprojection and pyproj transform give different values when selecting a pixel by point coordinates?

https://rasterio.readthedocs.io/en/stable/topics/reproject.html Rasterio can map the pixels of a destination raster with an associated coordinate reference system and transform to the pixels of a ...
user avatar
  • 5,632
1 vote

How to loop for create a multi-page TIFF (Layer Stack)

I like os walk in combination with collections defaultdict list for problems like this. You can store each date as a key, and the two files as values: import os from collections import defaultdict ...
user avatar
  • 51.2k
0 votes

GeoPandas reading coordinates in inverse order

You're passing the coordinates in the wrong order, shapely uses GIS axis order Point(x,y) so use: Point(response.point.longitude, response.point.latitude)
user avatar
  • 51.7k
0 votes

Cannot run semi-automatic classification (SCP) on Mac

I am having a similar problem. I have tried https://gis.stackexchange.com/a/370665/158608 Rachel has given an option here.. Go to Settings > Options > System > Environment Enable Use Custom ...
user avatar
0 votes

Extract by polygon from a rioxarray's raster

The answer was simpler than I thought, just calling zonal_stats from rasterstats: nbr_zonal = zonal_stats( vectors=polys, raster=nbr_mosaic[0,:,:].values, # since it's a 3D array affine=...
user avatar
  • 11.7k
1 vote

geopandas error "OSError: could not find or load spatialindex_c-64.dll" in PyCharm using OSGeo4W paths

To get geopandas working in a OSGeo Pycharm environment you need to import qgis processing using... from qgis import processing then... import geopandas will bring in the geopandas package EDIT ...
user avatar
  • 1,159
0 votes

Add projection to rioxarray dataset in Python

You are attempting to clip the whole dataset, but only the pr data var can be clipped. This is because it is the only one with both x and y dimensions. This should work: dset_shp = dset.pr.rio.clip(...
user avatar
  • 5,632
0 votes

Converting GEE Javascript to Python using geemap not working

In your python code you are using a client-side function (for loop) over server-side functions. That's the first error. Also, .lt doesn't work over image collections, only over images. So if you want ...
user avatar
  • 11.7k
3 votes
Accepted

What does "del aprx" at the end of Python code do?

In python del means delete the object which would release memory and file locks. So if you saw del abc,bob,x this would mean delete the objects abc, bob and x, what ever they are. aprx is the commonly ...
user avatar
  • 38.4k
2 votes

QgsVectorLayer no attribute setLayerName QGIS 3

Its .setName(). Use it like this: layer = iface.activeLayer() layer.setName('my new layername')
user avatar
  • 24.7k
3 votes

Getting wrong coordinates converting UTM to lon/lat with Proj

After trying your code I could get an error: pyproj.exceptions.CRSError: Invalid projection: +proj=utm +zone=24K, +south +ellps=WGS84 +datum=WGS84 +units=m +no_defs +type=crs: (Internal Proj Error: ...
user avatar
  • 22.9k
0 votes

Broadcast Shapely Point on numpy array

To add a update to Martijn Pieters answer. On shapely 1.8.0, the version I've tested the method on, using asMultiPoint will raise a error. However, simply switching to MultiPoint works. This is in ...
user avatar
4 votes

Getting wrong coordinates converting UTM to lon/lat with Proj

try "+proj=utm +zone=24 +south +datum=WGS84 +units=m +no_defs ". use epsg.io to identify the appropriate proj4 input, look at the bottom of the page. another alternative is just use epsg ...
user avatar
  • 622
0 votes
Accepted

Insert a waypoint into a POSTGIS table with psycopg2 and ST_GeographyFromText

You need to enclose your Point into single quotes: SELECT ST_GeographyFromText('POINT(48.07093 11.19797)') -> vs SELECT ST_GeographyFromText(POINT(48.07093 11.19797)) ERROR: syntax error at or ...
user avatar
  • 6,698
0 votes

Converting a epoch time number to a datetime stamp in a dataframe

Well this worked ['BaseDateTime'] = pd.to_datetime(df['date_num'], unit='s', utc=True) Not sure why the other suggestions didn't.
user avatar
  • 1,159
0 votes

Calculating the distance For each Row with respect to a Common Point

It looks like 'port.longitude' and 'fac.latitude' are correctly replaced in your f-string, but 'Warehouse.longitude' and 'Warehouse.latitude' are not and are left as string. The reason is you try to ...
user avatar
  • 1,722
0 votes

Polygonizing global raster using Python/GDAL?

You can indeed split a raster into smaller tiles, but you will need to know the extents of each tile. gdal_translate and -projwin will give you the result you want. Another solution, one I have used ...
user avatar
1 vote
Accepted

Converting ee.Image to numpy array in Earth Engine Python API takes too much time

sampleRectangle() is not the ideal way to retrieve image pixels from Earth Engine, because they'll end up converted to JSON and back. Try using ee.Image.getDownloadURL() — this can give you “NumPy ...
user avatar
  • 8,521
0 votes

How to stack list of Xarrays

To stack the array into shape (n_image, width, height), you need np.vstack. Check out https://numpy.org/doc/stable/reference/generated/numpy.vstack.html For 3 bands image e.g RGB you get shape (3,...
user avatar
2 votes

Looking for GeoPandas equivalents of PostGIS "ST_DumpRings" and "ST_Dump" tools

Try either .interiors: Returns a Series of List representing the inner rings of each polygon in the GeoSeries. .exterior Returns a GeoSeries of LinearRings representing the outer boundary of each ...
user avatar
  • 22.9k
1 vote

Converting x/y in Pandas DataFrame to lat/long

Firstly I recommend the os.path.splitext() function from the os.path module to get file_extension and output_file in a bit more elegant way: from os.path import splitext input_file = '.../input_file....
user avatar
  • 22.9k
1 vote

ShapefileException when reading shapefile using PyShp

I could also get the ShapefileException when: the path to a shapefile is wrong the shapefile's name was wrongly specified there is no permission to access the shapefile First of all, I suggest to ...
user avatar
  • 22.9k
2 votes

CRS is empty but GeoDataFrame plotted correctly when reading shapefile with GeoPandas

The shapefile is a bundle of files. One of them is the .prj. When reading a shapefile with GeoPandas and either: .prj is an empty file no .prj file at all the output will be None. So, in this case, ...
user avatar
  • 22.9k
0 votes

Count overlapping features using Geopandas

A better solution based on Parker Devine's answer def count_overlapping_features(gdf): #generating all of the split pieces import shapely bounds = gdf.geometry.exterior.unary_union ...
user avatar
  • 1
2 votes

Requests Python module in QGIS return nontype or empty CSV

Your code should work. I can't run/reproduce your code without an API key for the particular API you were using. I used the geonames.org API for a test. In your screenshot, it looks like your file is ...
user avatar
  • 1,261
1 vote
Accepted

Distance to nearest shape in Python

Thanks for the many interesting methods shared in comments. I decided to call QGIS functions from python directly as I needed other QGIS functions as well. I had some troubles to have the correct GQIS ...
user avatar
  • 39
3 votes
Accepted

Convert from latitude/longitude into feet and acres using Python

Use GeoPandas (and pyproj) to transform these to a better CRS: import geopandas import pandas as pd df = pd.read_csv("data_for_question.csv").set_index("Sample_ID") lat_lng_gdf = ...
user avatar
  • 39.7k
1 vote

Convert from latitude/longitude into feet and acres using Python

You will face a challenge in that the distance spanned (in ground coordinates, e.g. metres) by one degree of longitude is not constant. One degree longitude near the poles is vanishingly small. One ...
user avatar
  • 6,330
0 votes

Converting a epoch time number to a datetime stamp in a dataframe

The NetCDF4 library has a num2date() function which should handle this, w/o the need for the datetime module. # this is the NetCDF4 variable with all it's attributes, including time units. ...
user avatar
2 votes

"Has no attribute geometry" error when creating polygon with Shapely

I have seen your previous question, where I would like to extend @KadirŞahbaz's answer: from shapely.geometry import Polygon ... for steps in range(numVertices): pt = geom.vertexAt(steps) ...
user avatar
  • 22.9k
1 vote

Filter by bounding box in GeoPandas

A quick solution to this if the shape you want to clip by is a box: from shapely.geometry import box bbox = box(*df_sussex.total_bounds) df_clipped = gpd.mask(df, mask=bbox) It uses the shapely....
user avatar
4 votes
Accepted

WFS output limited to 1000

Check the service capabilities https://geoservices.noord-holland.nl/ags/services/oi_dataservice_alg/MapServer/WFSServer?request=GetCapabilities&service=WFS&version=2.0.0 <ows:Constraint ...
user avatar
  • 51.5k
0 votes

how to test if linear exists with a buffer with ArcPy

Use the Clip tool to get the geometry of the lines within the buffer, then compare the length of the clipped lines with the original lines to get your percentage within the buffer
user avatar
0 votes

How to add a band to xarray dataset using rioxarray

In case it's still useful, I found a method (although it's time consuming, and probably more so with your raster): import rioxarray as rxr import xarray as xr import os def merge_images(raster1, ...
user avatar
1 vote
Accepted

Using Shapely methods (explain_validity and make_valid) on shapefile

Two above method (explain_validity and make_valid) are applicable not to the shapefile itself, but to the objects (geometries of features) that it contains. To apply the explain_validity() method: ...
user avatar
  • 22.9k

Top 50 recent answers are included