Skip to main content
7 votes
Accepted

sf equivalent of R maptools package's SpatialLinesMidPoints

Looks like maptools:::getMidpoint, which underpins maptools::SpatialLinesMidPoints, can be applied to a LINESTRING geometry set without too much modification, e.g. st_line_midpoints <- function(...
obrl_soil's user avatar
  • 3,782
6 votes
Accepted

Bind polygon centroid to polygon attribute data

Load libraries and example data # Load libraries library('raster') library('geosphere') library('mapview') # incredible interactive map visualization in R # Get SpatialPolygonsDataFrame object ...
Guz's user avatar
  • 3,176
5 votes
Accepted

PyQGIS/QGIS2.18 : Get currently active map tool

One issue with trying to get the name of the tool is that not all tools have a name to begin with. For example, when using the Select Feature(s) tool, it's tool name is: iface.mapCanvas().mapTool()....
Joseph's user avatar
  • 76.3k
4 votes
Accepted

Wait for user selection from user interface

It's difficult to tell exactly without the full code, but I noticed you're calling self.selectionList_dlg.show() I suspect this should be self.selectionList_dlg.exec_() As exec_ will wait till ...
ndawson's user avatar
  • 27.9k
4 votes

Plotting shapefile in R: how to delete selected borders?

E.g. with gUnaryUnion from the rgeos package: library("rgeos") plot(gUnaryUnion(xx), col = "red", axes = TRUE) plot(gUnaryUnion(xx[c(9, 31, 82), ]), col = "blue", add = TRUE)
rcs's user avatar
  • 3,894
4 votes
Accepted

How to create a map tool with QgsMapToolEmitPoint that has snapping functionality?

You need to sub-class QgsMapToolEmitPoint instead of using the default implementation. Here is a basic example: class CustomMapTool(QgsMapToolEmitPoint): def __init__(self, canvas): self....
Ben W's user avatar
  • 23.1k
4 votes
Accepted

PyQGIS how to not select objects that are hidden by a layer style?

Here is a solution based on this answer by Yoann Quenach de Quivillic. You can add this function: def get_visible_selected_features(self): renderer = self.layer.renderer().clone() ctx = ...
JULESG's user avatar
  • 1,647
3 votes
Accepted

crop wrld_simpl gives error after R update

This is because of changes in the rgeos package. The problem appears to go away if you do as the error message says: consider using set_RGEOS_CheckValidity(2L) library(raster) library(maptools) data(&...
Robert Hijmans's user avatar
2 votes

simple plotting of (latitude, longitude) points on a global map

Sample code. Given a world map (e.g. lat: 80 ~ -80, lon: -160 ~ 160) was downloaded as PNG ("Downloaded_Image.png"). library(png) Downloaded_Image <- readPNG("Downloaded_Image.png") library(...
Kazuhito's user avatar
  • 31.2k
1 vote
Accepted

Colouring wrld_simpl countries with a variable

Its using the integer value behind the factor for the colouring, and then getting the colour from the current palette. Convert the factor to character if you want to use a factor column's levels as ...
Spacedman's user avatar
  • 66.5k
1 vote
Accepted

How to remove outliers from spatial polygon

First to the issue of your data. As hinted at by @Dataform in the comments, it appears that the Jung district of Busan has accidentally been coupled with the Jung district of Incheon in the GADM data. ...
humperderp's user avatar
1 vote
Accepted

Error in converting shapefiles into spatstat window

library(rgeos) #required by maptools library(maptools) library(spatstat) sca <- readShapeSpatial("KOR_adm1.shp") #upload Korean provinces sca <- sca[sca@data$NAME_1 %in% c("Seoul", "Incheon", "...
syre's user avatar
  • 417
1 vote
Accepted

Mapping data: error in classIntervals: var is not numeric

You've done this: breaks <- classIntervals(EU_NUTS@data$X2012._Y20.64_T, n = 5, style = "fisher", unique = TRUE)$brks which is trying to get a column called "X2012._Y20.64_T". Does that ...
Spacedman's user avatar
  • 66.5k
1 vote
Accepted

Kernel Density Map points rejected as outside window

The best explanation I could suggest looking into is similar to this response I found in a different forum, Warning message: points were rejected as lying outside the specified window. These points ...
whyzar's user avatar
  • 12.1k
1 vote

Merging multiple SpatialPolygonDataFrames into 1 SPDF in R?

library(sp) data(meuse) plot(meuse) slotNames(meuse) #".Data" "names" "row.names" ".S3Class" coordinates(meuse) <- ~x+y #Add "ID" column to "meuse" slotNames(meuse) #[1] "data" "...
Mox's user avatar
  • 1,036

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