Questions tagged [matplotlib]

If you are thinking about using this tag then perhaps reconsider whether your question would be better posted to Stack Overflow because "matplotlib is a python 2D plotting library" rather than GIS software.

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

Plotting Dataset of netCDF using matplotlib.pyplot displays rotated plot

I have read a Dataset in NC file using netCDF4 in python and then tried to plot the dataset using matplotlib.pyplot. But issue is the plot shows the image but with 90 Degrees clockwise rotation. ...
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 ...
0
votes
1answer
34 views

What is meaning of scale on x and y axis of image using matplotlib

I am finding elevation of a region using richdem. Can somebody tell me what is the meaning of the scale which is on the x and y axis of the image? import os import numpy as np import matplotlib ...
0
votes
0answers
42 views

Displaying projection with IMSHOW()

I am having an issue displaying satellite data on the correctly projection using cartopy and imshow. I am unsure of the initial data projection, but I am trying to put it into Plate Carree with a ...
1
vote
0answers
3k views

Reading shapefile faster using Python basemap (and pickle)

I am trying to plot a simple 'merc' map with boundary from shapefile. The total size of the shapefile ne_10m_admin_0_countries_lakes.shp is just 8mb. The simple mslp surface plot from GFS data took ...
2
votes
1answer
1k views

Hide meridians and parallel lines from plot and add TICK marks in matplotlib?

I want to hide the meridian and parallel lines from my plot and add the tick marks. I could remove the lines by setting linewidth=0, but how to add the tick marks with each Lat-Lon label. meridians =...
0
votes
1answer
118 views

using histogram2d with categorical dimension

This is a scatterplot of business addresses in Melbourne by ANZSIC division names. sns.pairplot(x_vars=["x coordinate"] , y_vars=["y coordinate"] , data=d , hue=...
2
votes
0answers
551 views

Calculating size of area where data values exceed certain limit

I am using Python and Basemap to plot sea ice concentration within the Arctic region. I need to calculate the total area (square meters) where the sea ice concentration exceeds a certain limit (e.g. ...
3
votes
1answer
978 views

Altering legend labels in Matplotlib

I have a choropleth map which displays crime percentage change. It is plotted from a geodataframe and the choropleth intervals are determined in the background by Python. Unfortunately, the first ...
2
votes
1answer
213 views

Setup shadedrelief background in basemap using a cropped orthographic projection

I'm trying to plot a sector of the world in basemap using an orthographic projection and I would like to have a shadedrelief background. If I don't use shadedrelief everything works fine: import ...
1
vote
0answers
48 views

Single country coastlines in Python Matplotlib Cartopy

In the image below I am using cartopy to plot coastlines. But, I only wish to have the coastlines of Australia, and not the surrounding countries. Is there a way to remove the other countries. Here ...
0
votes
1answer
98 views

Plot shapefile with islands with matplotlib

I am trying to plot a city shapefile with matplotlib's plt.plot()-function. However, within the closed areas I occasionally have small "islands" which lie within the city but not part of it. Therefore ...
0
votes
1answer
144 views

Touching Polygon Intersection

I have two touching Polygons (two neighbouring counties) and there intersection is a MultiLineString, where: len(list(counties["King's Co."].intersection(counties["Queen's Co."]).geoms)) list(...
3
votes
1answer
443 views

Matplotlib integration in QGIS

I just made some experiments with Matplotlib and what i noticed is that all that is generated using matplotlib appear in a new window that doesn't seem to be tightly linked to qgis. The only "link" i ...
2
votes
3answers
10k views

Visualizing.tif image using Python

I am trying to read a hyperspectral image in Uint16 .tif format and visualize it. I use GDAL in Python to read the data and everything works perfectly when I use matplotlib to show one band of the ...
0
votes
1answer
129 views

Plot RGB using rasterio

When plotting and RGB image using rasterio, I have seen that it is necessary to normalize the values first (0-1) and the use show. I am using the following code for that: def norm(band): band_min,...
2
votes
0answers
102 views

Add WMS to matplotlib Python

Currently I am adding a basemap from stamen.com to my plots as it is explained here: http://geopandas.org/gallery/plotting_basemap_background.html . Is it also possible to load a WMS from another ...
3
votes
3answers
546 views

Colorizing polygons based on color values in dataframe column?

I preparing some choropleth election result maps in Geopandas. The assigned color for each electoral district must correspond with the winning party (a color that I pre-determine), and the intensity ...
2
votes
1answer
67 views

Fixing colors of LISA Cluster maps from Pysal?

I am using the LISA Cluster package from Pysal to create a LISA (Local Indicator of Spatial Autocorrelation) map. As the example of the documentation shows, the color lightblue is used to identify ...
1
vote
0answers
147 views

Plotting TIFF File on tkinter Canvas

I have a TIFF file which I am trying to plot on tkinter canvas using the following code: import tkinter from matplotlib.backends.backend_tkagg import ( FigureCanvasTkAgg, NavigationToolbar2Tk) # ...
0
votes
2answers
711 views

GeoPandas: plot two layers but only to the extent of the smaller one

I am using GeoPandas and I want to plot two layers. I want the map to have the extent of the smaller layer. With this code below, the map's size automatically fits the bigger layer. import geopandas ...
0
votes
1answer
194 views

How to put a Google Map image (or any other map layers) under my UTM cordinates plot uding matplotlib and Python?

I am plotting the route taken by a car on a graph, using matplotlib. I have the cordinates of the car over time and I have extracted them in UTM cordinates (tile 31U). Below are the arrays. x = [...
0
votes
1answer
263 views

GeoPandas plot does not work

I am running this code import geopandas df = geopandas.read_file('test.geojson') ax = df.plot(figsize=(10, 10), alpha=0.5, edgecolor='k') and I get nothing besides this error /usr/local/lib/python3....
4
votes
4answers
5k views

Plotting large shapefiles with matplotlib

I'm writing a little GIS tool in Python and I want to display shapefiles. I've successfully gotten matplotlib working using this answer, but it is very slow and heavy to load any shapefile that ...
4
votes
1answer
586 views

Center / normalize choropleth colors in GeoPandas

I'm looking to plot a choropleth with a divergent colormap. I need to center the colormap in such a way that the middle color is displayed for a specific value (e.g. 0). How could I do this in ...
7
votes
1answer
5k views

Plot shapefile on top of raster using plot and imshow from matplotlib

I need to plot a shapefile on top of a raster. I would like to use the python package rasterio and some combination of fiona or geopandas to load the shapefile. I found an example in the rasterio ...
0
votes
0answers
135 views

GeoPandas plot choropleth line color

I'm using GeoPandas to create a categorical choropleth of my data. I managed to get the correct colormap applied to the polygon fill but there are tiny slivers between the polygons that I would like ...
2
votes
0answers
42 views

Run Schelling's model of segregation on a geographical map instead of the matplotlib plot or grid

If you don't know what is Schelling's model of segregation, you can read it here. I have written the following code to run the Schelling's model of segregation simulation. import matplotlib.pyplot ...
1
vote
0answers
243 views

Converting coordinates using NCO/CDO

I have a NetCDF file of ice velocities of the Greenland ice sheet but they are in polar stereographic coordinates (y: -655750 to -3355750 and x: -639750 to 855750 meters). I am wondering if there ...
1
vote
0answers
16 views

Store the lat long coordinates in matplotlib figure to a table in Python

The matplotlib figure is made of polygons and I want to take the centroid of each polygon and convert it into raster data and store it in a table.
1
vote
1answer
357 views

Visualizing LAS with matplotlib

I'm trying to create a 3D scatterplot using an las file that contains xyz and return values. I want to keep all returns but would like to subset the cloud. I've learned how to subset using laspy so no ...
0
votes
0answers
27 views

Reading dataset of NetCDF file

I have 2 NC files having the same dataset which I am reading by using netCDF4 in Python. After reading one of the NC file, the dataset is getting properly displayed by using np.rot90(data) which was ...
37
votes
4answers
25k views

Simple thematic mapping of shapefile using Python?

I wish to visualize geographical data in Python, without using ArcGIS/ArcPy, and make a map. On the internet I found how to make a thematic map using Python: Here is some code that I tried: ...
0
votes
1answer
2k views

Plotting 3D Data using Python?

I have a Uniform Grid of 1KMx1KM squares as a shapefile with population data in each grid in a specific column as an integer. I would like to extrude each polygon based on the population and export ...
0
votes
0answers
221 views

Basemap and EPSG 3857

I have my MatPlotLib basemap set up in Mercator projection: map = Basemap(projection='merc', llcrnrlon=-10., llcrnrlat=30., urcrnrlon=36.5, urcrnrlat=46.) I need to create an ...
0
votes
0answers
79 views

Saving matplotlib map to shapefile in python?

I already plot a prediction map I made with xgboost modal by matplotlib function and I want to save this map as a shapefile so I can work with it in ArcGIS, how can I do that? Picture of the map:
2
votes
1answer
132 views

Converting QgsRaster object to array

So I'm a newbie, so sorry if this is an idiot question. I'm trying to write a plugin for QGIS3 for my organisation, and I'd like to output a standalone figure (i.e. not in the QGIS window) as the ...
1
vote
1answer
1k views

Increasing resolution of Cartopy stock background?

I am trying to create a small application that will show zoomed in maps. If possible, I would like to avoid using map tiles. Going off the example on this page: https://scitools.org.uk/cartopy/docs/...
8
votes
1answer
9k views

Plotting raster maps in python?

I am trying to plot raster map using Pyhton. Image is not being saved, though it appears. Moreover, pixels are not appearing on the exact place. I am getting image as shown below (which is WRONG, ...
1
vote
1answer
93 views

Visualization of 11-bit images

I'm trying to visualize a 11-bit TIFF image using matplotlib. To do it, I load the image using tifffile to obtain a 3D numpy array. Next, I have to down-sample the image because the array contains ...
13
votes
6answers
40k views

Plot shapefile with matplotlib

I am trying to read a shapefile and plot it using matplotlib. Here is the code: import matplotlib.pyplot as plt import shapefile shpFilePath = "D:\test.shp" listx=[] listy=[] test = shapefile....
4
votes
1answer
848 views

Using arcpy.RasterToNumPyArray() to Graph Raster with matplotlib? [closed]

Can you use arcpy.RasterToNumPyArray() to Graph a Raster with matplotlib? I'm looking to graph a raster with X, Y, and Z values in a 3D bar graph. I just can't seem to translate the numpy array to ...
0
votes
0answers
108 views

NDVI Python image showing inverse

I am trying to calculate NDVI using python and landsat imagery. I am able to calculate ndvi using the following equation: def ndvi(sat, fp): raster = rasterio.open(fp) if sat.lower() == 'l8': ...
2
votes
1answer
774 views

Matplotlib Basemap Resolution with PyQt makes Python Quit Unexpectedly

I'm having difficulties using Matplotlibs Basemap in combination with a PyQt4 interface. Basically I create a Pyqt4 Canvas in which I plot a Matplotlib Basemap and some markers. I call the function in ...
0
votes
1answer
403 views

Using Rasterio, Matplotlib, and Numpy trying to calculate and plot NDVI of a raster image getting error: IndexError: list index out of range?

First I create two variables and store my raster images in them and I use MatPlotLib to plot a subset of the original "nirband" raster image. That works fine. I am getting an IndexError: list index ...
1
vote
1answer
370 views

Using rasterio and matplotlib how can I create a window for an NDVI image to fit into?

I am using Rasterio, Numpy, and Matplotlib. I created a window with the dimensions of 800x600 and plotted the band 5 for a Landsat 8 image, that worked just fine. I also have the nir image so then I ...
1
vote
1answer
881 views

Can't import shapefile in Python

I am trying to plot district boundaries on a map of Nepal. For that I downloaded a shapefile of districts in Nepal from this site: http://www.arcgis.com/home/item.html?id=...
0
votes
2answers
963 views

Plotting “diagram” in matplotlib? [closed]

I want to plot a diagram like this: http://matplotlib.org/examples/shapes_and_collections/scatter_demo.html Unfortunately, I have no idea what these diagrams are called and therefore I do not know ...
3
votes
1answer
772 views

How to define boundary numbers without decimal points - Geopandas

Problem The numbers in a legend has the decimal points (eg. 0.00-4.80 at the top of the legend box), when I want them to be integers without decimal points. All I care is that the boundary values are ...
0
votes
1answer
346 views

How to append geojson file using featureselection

For example, I have a file as shown below: { "type": "FeatureCollection", "features": [ { "type": "Feature", "properties": {}, "geometry": { "type": "...