11 votes
Accepted

Measuring compactness in Python

You don't need to create circles. The formula is derived from the ratio you mentioned. Use the following script. You can apply the other formulas easily. import geopandas as gpd from math import pi, ...
user avatar
8 votes

Raster data viewshed analysis with Python

The easiest way to calculate a visibility raster in python is to call the ad hoc functions of a GIS from your code. This can be done in several ways (non-exhaustive list): Using the r.viewshed module ...
user avatar
  • 1,259
7 votes
Accepted

Ipyleaflet map object doesn't display in Jupyter Notebook but it gets created

I just tried to install ipyleaflet with Jupyter 5.2.3: conda install -c conda-forge ipyleaflet and also didn't get a map. I then tried registering the extension with: jupyter nbextension enable --...
user avatar
  • 3,897
6 votes
Accepted

`folium.GeoJson` displays all polygons in GeoDataframe but not individual ones

Because gdf["geometry"]) is a GeoSerie and gdf["geometry"][0] is a shapely geometry (the geometry column is a list of shapely geometries). The type of data data=gdf["geometry&...
user avatar
  • 51.2k
6 votes

GDAL ImportError: DLL load failed: The specified module could not be found

I had the same exact problem. I fixed it by: Uninstalling Anaconda and reinstalling, making sure the "Add anaconda to PATH" option was ticked. Installing geopandas with conda install -c conda-forge ...
user avatar
  • 101
5 votes

ipyleaflet draws?

Going from the Draw Control example you can add a callback to the Draw Control that will get passed the GeoJSON from the feature: from ipyleaflet import Map, basemaps, basemap_to_tiles, DrawControl ...
user avatar
  • 15.3k
4 votes

Choosing Google Earth Engine IDE

You can edit your scripts with any IDE you want as long as you include git into your workflow. All the scripts you see are based in git repositories (see GEE docs): The Scripts manager stores ...
user avatar
  • 9,450
4 votes
Accepted

Choosing Google Earth Engine IDE

If you are able to use Jupyter Notebook or Lab, I have made a "code editor simulator". Initially I made two ways of using it, one via folium and the other one via ipyleaflet, but I have been ...
user avatar
4 votes

Google Earth Engine Python expression syntax

Here is the Python equivalent of your function: def addEVI(image): EVI = image.expression('2.5 * ((NIR - RED) / (NIR + 6 * RED - 7.5 * BLUE + 1))', { 'NIR' : image.select('B8').divide(...
user avatar
3 votes
Accepted

Using external table to iteratively change parameters into ArcPy code

Create a view of the excel table using Make table view Read the values row by row with da.SearchCursor With string format construct the input parameters strings Something like: import arcpy arcpy....
user avatar
  • 52.5k
3 votes
Accepted

How to use Planet Lab tiles in Jupyter Notebook?

One thing that looks wrong is tiles{0}. Try just tiles. If that works, then try tiles{s} for a small performance improvement. The other issue is the order of x, y and z in the tile URL. It should be {...
user avatar
  • 1,522
3 votes

Subsetting a large CSV file using coordinates columns

You can read a CSV one line at a time, deal with that line, then either output it or skip to the next one. Tutorials on reading CSV files in python using the csv module from the standard library are ...
user avatar
  • 52.1k
3 votes

Folium and heatmap is not opening in pycharm

I think the first port of call with this would be to check what your browser is telling you when you open your html file. In the browser open the file you create and hit F12. This will open the "...
user avatar
  • 3,429
2 votes
Accepted

Google-Earth-Engine + Jupyter : filterBounds not working in Landsat imageCollection

For the ee.Geometry.Point() constructor, the dimension ordering of the coord parameter is longitude,latitude (or x,y), rather than latitude,longitude. Once you reverse your parameters, you should see ...
user avatar
2 votes
Accepted

Building Docker image including IPython Notebook and EE?

The tylere/docker-tmpnb-ee repository is not longer being maintained. Development has moved to https://github.com/gee-community/ee-jupyter-contrib
user avatar
2 votes
Accepted

Set georeferenced extents of VRT file when calling GDALBuildVRT

After doing some digging, the answer is within the documentation, but not on the main BuildVRT page: http://gdal.org/python/osgeo.gdal-module.html#BuildVRTOptions The answer to my above question is ...
user avatar
  • 315
2 votes
Accepted

Jupyter and ArcGIS error: arcpy needs to run within an active ArcGIS Conda environment

This is how i got it to work on a new computer (i did not know of ArcGIS Package Manager when i did this): Install ArcGIS Pro (i use version 2.0.1) in a folder so the path have no whitespaces, for ...
user avatar
  • 52.5k
2 votes

Transforming an image (TIFF) into an array

This image has 5 bands. A simple RGB image has 3 bands, or 4 when it has the alpha band. So to process, it creates the empty Numpy.Dataset(x,y,z): img_b1 = np.zeros((ncol,nrow,nband),dtype=dtype) ...
user avatar
2 votes
Accepted

ipyleaflet with GEE in JupyterLab doesn't show layer

The EE Python API has been updated, breaking backwards compatibility. This is the way you get the tile URL these days: def GetTileLayerUrl(ee_image_object): map_id = ee.Image(ee_image_object)....
user avatar
  • 9,645
2 votes

Make a list from shapefiles using GeoPandas

I assume that all shapefiles include these attributes: ISO3, geometry, PA_DEF, STATUS_YR import os from glob import glob import geopandas as gpd # get list of .shp file names in shp_folder ...
user avatar
2 votes
Accepted

Request Sentinel1 data with sentinelhub API doesn't work

The error mentions there is a layer missing in the Sentinel Hub configuration you are using to perform a WMS request. See documentation on how to configure your account before using sentinelhub-py. If ...
user avatar
  • 754
2 votes
Accepted

Rasterio doesn't show the coordinates when using "imshow "

Your used matplotlib.pyplot.imshow() to show the first grayscale image, and rasterio.plot.show() for the second RGB one. Use show() to display the first grayscale image (Band 4), too; from rasterio....
user avatar
  • 29.1k
2 votes
Accepted

Adding query layer to MapView in Jupyter Notebook returns "RuntimeError: Cannot infer layer: will not be added to map"

You're running into the same problem/answer here: Adding data using Python from ArcGIS Online/ArcGIS REST Services directory to a ArcMap MXD --just reversing the layers and the map technology. You're ...
user avatar
  • 15.4k
2 votes
Accepted

Downloading RGB Sentinel-2 with Google Earth Engine and Python

You could try to define visualization parameters and then make a new variable where you add the visualization. It would look something like this: var vis = { min: 0, max: 3000, bands:['B4','B3','...
user avatar
2 votes
Accepted

Not able to plot Open Data Cube dataset image

I think this might be able to be solved just by running plt.show() after calling the .plot() method. Another issue I have sometimes encountered is importing matplotlib and then plotting something in ...
user avatar
  • 298
2 votes

Unable to load the data product of Open Data Cube dataset image

Usually if you get an empty return, there is no data over your area of interest. Try loading a dataset searching by extents, like this: datasets = dc.find_datasets(product='AWiFS_21May19', limit=1) ...
user avatar
  • 13.1k
2 votes
Accepted

Subsetting a large CSV file using coordinates columns

Based on this SO answer you could iterate the CSV in chunks: import geopandas as gpd import pandas as pd xmin, ymin, xmax, ymax = 127, -18, 128, -17 with pd.read_csv("/tmp/test.csv", ...
user avatar
  • 52.8k
1 vote

Saving created .kea files

It turns out I had the different version of Gdal installed and that's why it did not work.
user avatar
1 vote
Accepted

Display a gee featureCollection on a leaflet map

I presumed there would be an easy way to convert FeatureCollection to GeoJSON and load up as a layer in ipyleaflet but it is not straightforward. As far as I can see there is no direct way of doing ...
user avatar
  • 4,806
1 vote

ValueError: too many values to unpack (expected 2)

The problem seems to be that the split() functions returns more value than the variables used on the left side of the = operator. I quickly tried the following code snippet: s = "./...
user avatar
  • 1,151

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