Hot answers tagged

10

It's not possible to convert GEDI .h5 file to LAS file as including all data. Because that .h5 file includes a lot of information about a point (actually it is a window in GEDI .h5 format, not point). You cannot add all information to LAS file since LAS file has certain attributes for a point not matching attributes/values in that .h5 file. For example, ...


7

Ideally there would be some way to convert EE image objects to sklearn-readable NumPy arrays directly using the EE Python API. ee.Image.sampleRectangle() does this. However, there is a limit of 262144 pixels that can be transferred. The interactive data transfer limit is in place to protect your system from hanging (it is easy to request terabytes of data ...


6

I tried several coordinate systems for Florida and the various State Plane Florida East zone but the coordinates just didn't seem to fit. Google kept finding the address in Hempstead, NY, so I tried the Long Island zone, unit of US survey feet, and the results look good. Try EPSG::6539 for the NAD83 (2011) version or EPSG::2908 for NAD83 (HARN). For the ...


4

You can first union all polygons with unary_union: single_multi_polygon = all_Rapa_Nui.unary_union This should now be a single MultiPolygon consisting of two polygons for the two islands. And then you can get the polygon parts of this MultiPolygon: polygons = single_multi_polygon.geoms


4

The error message that you get indicates that there is something wrong with your input dataset. I think this is because there are formatting and syntax errors in your code. I have edited your script so that it should work: import pandas as pd from osgeo import gdal import os df = pd.read_csv("azimut_altitude.csv") src_ds = gdal.Open("my_raster.tif") #...


4

What I've done is download the images as tifs from GEE (something you might have to do in pieces given the size). I used the getDownloadURL() function because it is faster, even though I've read that the preferred way is to use 'Export.image.toDrive()'. Then, with my bands as separate tifs, I stack them together using rasterio/GDAL into one tif. I keep them ...


4

There would be many was to do this, the method I use is to write my CSV file directly: with open("C:\\Users\\ARSH\\Desktop\\ndvir.csv",'w') as WriteCSV: for ThisRow in array: WriteCSV.write(str(ThisRow)[1:-1] + '\n') Using the with operator ensures the CSV file is closed at the end. str(ThisRow) returns '[val,val...val]' so using the string ...


3

You may be interested in geocube (https://github.com/corteva/geocube): Examples: https://corteva.github.io/geocube/stable/examples/examples.html from geocube.api.core import make_geocube gdf = geopandas.read_file(...) cube = make_geocube(vector_data=gdf, measurements=["column_name"], resolution=(16, -16)) out_grid["column_name"].rio.to_raster("...


3

The issue is that array.astype() is not applying any stretching or scaling, you need to do that yourself to make the input range of 16-bit values (2^16-1 == max of 65535) fit into an 8-bit integer (2^8-1 == max of 255). You're getting integer overflow leading to that wonky image, values larger than that 8-bit max are wrapping back around from the minimum. ...


3

Using the https://overpass-turbo.eu/ Wizard and some adjustments, I managed to create a query for retrieving the metadata of a specific way (i.e. id:421427136): /* This has been generated by the overpass-turbo wizard. The original search was: “id:421427136” */ [out:json][timeout:25]; // gather results ( // query part for: “id:421427136” way(421427136); )...


3

For anyone interested, here is an implementation of a CheckableComboBox. class CheckableComboBox(QComboBox): # Subclass Delegate to increase item height class Delegate(QStyledItemDelegate): def sizeHint(self, option, index): size = super().sizeHint(option, index) size.setHeight(20) return size def ...


3

In geopandas <= v0.6.3., gdf.crs returns a dictionary like {'init': 'epsg:EPSG_CODE'}. So, more appropriate way is to use tools of geopandas defined in geopandas.tools module. geom_srid_num = gpd.tools.crs.epsg_from_crs(gdf.crs) print(geom_srid_num) # OUT: 32616 -> int EDIT: As @snowman2 states in comment, epsg_from_crs is deprecated in geopandas v0....


3

Use like this: root = QgsProject.instance().layerTreeRoot() test = root.children()[0] testClone = test.clone() root.insertChildNode(1, testClone) root.removeChildNode(test)


3

Using the script of Intro to Python Gis: Raster calculations and the data from EarthPy: vignette "earth-analytics" import rasterio import numpy as np b4 = rasterio.open("/earth-analytics/data/vignette-landsat/LC08_L1TP_034032_20160621_20170221_01_T1_sr_band4_crop.tif") b5= rasterio.open("/earth-analytics/data/vignette-landsat/...


2

If you mean rasterizing your polygon, I recommend geocube Here is a simple example assuming the data is in the WGS 84 projection: import geopandas as gpd from geocube.api.core import make_geocube gdf = gpd.GeoDataFrame({"mask": [1]}, geometry=[shapely_geom], crs="EPSG:4326") cube = make_geocube(gdf, resolution=(-0.001, 0.001), fill=0) arr_mask = cube....


2

How about something like this, try: gdf = geopandas.read_file(shape) except DataIOError as err: # log error if you want # log(str(err)) raise TypeError clip(raster, shape) Good all try/except Edit: Just to add some links fiona open doc, geopandas read_file is based on fiona open geopandas io doc.


2

The accepted answer does not work in QGIS3. Now one has to do: fieldname='id' layer=iface.activeLayer() idx=layer.fields().indexFromName(fieldname) print(layer.maximumValue(idx)) (I am setting fieldname as the first line to make it easier to cut and paste for someone wanting to test it with their layer)


2

You need to be more careful about your code. Already when you write layer = fields you change your dataframe to become a simple list. Your function denom doesn't return anything, and it should return a dataframe given how you use it in the multiprocessing. You never use Parallel in your code (it does not exist indeed), but use Pool. That's what you ...


2

Vast question, a matrix distance is really not the way to go for a lot of points. If you want to do it yourself, look into quadtree and nearest neighbourg. The classicals algorithms used for clustering would be DBScan or Kmeans, but for your exemple you can simply use Postgis and the function ST_ClusterWithin (and you can test ST_ClusterDBSCAN and ...


2

You can use Qt.MatchContains flag as filter mode. from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QCompleter completer = QCompleter() completer.setFilterMode(Qt.MatchContains) For further information: Filter Modes for QCompleter.


2

You must mix the data_type in the gpkg_contents table with the geometry_type_name in the gpkg_geometry_columns table. "Features" is what you are supposed to see as data_type. http://www.geopackage.org/spec121/index.html#_gpkg_contents The data_type specifies the type of content contained in the table, for example "features" per clause Features, "...


2

As a quick answer, most transforms are more complex than a scale/translate/unit, so you are looking for exceptions. The distortion come from the change in datum (that is the transformation, from lat/long to lat/long) and from the type of projection (from lat/long to XY). Having the same (or rotated around the vertical) datum is a prerequisite but, if you ...


2

The python module gdal2tiles is not in the path by default I'm able to import it using conda create --name gisenv python=3.6 conda activate gisenv conda install gdal Then, running the following in python does work import os import sys sys.path.insert(0, os.path.join(os.environ['CONDA_PREFIX'], 'bin')) import gdal2tiles I'm surprised you don't use the ...


2

In this case, layer is an instance of QgsVectorLayer, because currentLayer gives you that. But ogr.Open() needs a path. So you need to get layer source to pass to ogr.Open(). QgsVectorLayer class has source method which gives you full path of the layer source. Use in that way: layer = self.dlg.mMapLayerComboBox.currentLayer() layer_path = layer.source() ...


2

Not really GIS related, but you can use the astype method: geo_df['denominator'] = df[["basalareap","basalareas","basalaread"]].sum(axis=1).astype(str)


2

Fiona does not have spatial operations such as clipping, intersections, unions, etc. The user manual, "explains how to use the Fiona package for reading and writing geospatial data files. " It states: There are no layers, no cursors, no geometric operations, no transformations between coordinate systems, no remote method calls; all these concerns ...


2

I agree with @mikewatt, that a good way to handle the error would be to capture it by using try and catch. But if you want to check that condition, you could do something like this, def correctPolygon(s): geoj = s.__geo_interface__ coords = geoj['coordinates'] # check if it is a polygon if geoj['type'] != 'Polygon': return False ...


2

One option would be to create a python action for each layer filter you want to set. The action can call the setSubsetString()method on the layer setting the attribute expression. See this q/a for a basic example using setSubsetString(): Subsetting a shapefile and saving it using PyQgis See link below for how to create a python action. Creating Custom ...


2

You're right. QComboBox objects allow only single selection because they don't have ExtendedSelection option (as QListWidget objects) for activating multiple selection. However, you can also use a QTableWidget object whose ExtendedSelection option is already activated by default. In following code you have an example. from PyQt5.QtCore import Qt class ...


2

Take a look at np.where and maybe do something like: y_true= np.ravel(img_r) y_pred= np.ravel(img_pre_r) y_true = y_true.astype('int') y_pred = y_pred.astype('int') indx = np.where((y_true != -9999) & (y_true != 205) & (y_true != 210) & (y_true != 215)) y_true = y_true[indx] y_pred = y_pred[indx] Or apply the np.where call to both true and ...


Only top voted, non community-wiki answers of a minimum length are eligible